Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-10-22 07:04:23
Exec Total Coverage
Lines: 1666 4283 38.9%
Functions: 130 332 39.2%
Branches: 925 2930 31.6%

Line Branch Exec Source
1 #include "zc/zc_sys.h"
2
3 #include "allegro/gfx.h"
4 #include "allegro5/joystick.h"
5 #include "base/qrs.h"
6 #include "base/dmap.h"
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <cstring>
10 #include <math.h>
11 #include <map>
12 #include <filesystem>
13 #include <ctype.h>
14 #include <sstream>
15 #include "base/zc_alleg.h"
16 #include "gamedata.h"
17 #include "zc/zc_init.h"
18 #include "init.h"
19 #include "zc/replay.h"
20 #include "zc/cheats.h"
21 #include "zc/render.h"
22 #include "base/zc_math.h"
23 #include "base/zapp.h"
24 #include "dialog/cheatkeys.h"
25 #include "metadata/metadata.h"
26 #include "zc/zelda.h"
27 #include "zc/saves.h"
28 #include "tiles.h"
29 #include "base/colors.h"
30 #include "pal.h"
31 #include "base/zsys.h"
32 #include "qst.h"
33 #include "zc/zc_sys.h"
34 #include "play_midi.h"
35 #include "jwin_a5.h"
36 #include "base/jwinfsel.h"
37 #include "base/gui.h"
38 #include "midi.h"
39 #include "subscr.h"
40 #include "zc/maps.h"
41 #include "sprite.h"
42 #include "zc/guys.h"
43 #include "zc/hero.h"
44 #include "zc/title.h"
45 #include "particles.h"
46 #include "zcmusic.h"
47 #include "zconsole.h"
48 #include "zc/ffscript.h"
49 #include "dialog/info.h"
50 #include "dialog/alert.h"
51 #include "zc/combos.h"
52 #include "zc/jit.h"
53 #include "zc/zc_subscr.h"
54 #include <fmt/format.h>
55 #include "zinfo.h"
56 #include "base/misctypes.h"
57
58 #ifdef __EMSCRIPTEN__
59 #include "base/emscripten_utils.h"
60 #endif
61
62 using namespace std::chrono_literals;
63
64 extern FFScript FFCore;
65 extern bool Playing;
66 int32_t sfx_voice[WAV_COUNT];
67 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
68 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
69
70 static ALLEGRO_JOYSTICK* gamepad_dlg_cur_joystick;
71 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c);
72
73 extern byte monochrome_console;
74
75 extern HeroClass Hero;
76 extern zcmodule moduledata;
77 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
78 extern particle_list particles;
79 extern int32_t loadlast;
80 extern char *sfx_string[WAV_COUNT];
81 byte use_dwm_flush;
82 byte use_save_indicator;
83 int32_t paused_midi_pos = 0;
84 byte midi_suspended = 0;
85 byte zc_192b163_warp_compatibility;
86 char modulepath[2048];
87 bool epilepsyFlashReduction;
88 signed char pause_in_background_menu_init = 0;
89 byte pause_in_background = 0;
90 bool is_sys_pal = false;
91 static bool load_control_called_this_frame;
92 extern PALETTE* hw_palette;
93 extern bool update_hw_pal;
94 extern const char* dmaplist(int32_t index, int32_t* list_size);
95 int32_t getnumber(const char *prompt,int32_t initialval);
96
97 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
98 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
99
100 static const char *qst_module_name = "current_module";
101 #ifdef ALLEGRO_LINUX
102 static const char *samplepath = "samplesoundset/patches.dat";
103 #endif
104 char qst_files_path[2048];
105
106 #ifdef _MSC_VER
107 #define getcwd _getcwd
108 #endif
109
110 bool rF11();
111 bool rI();
112 bool rQ();
113 bool zc_key_pressed();
114
115 #ifdef _WIN32
116
117 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
118 extern "C"
119 {
120 typedef HRESULT(WINAPI *t_DwmFlush)();
121 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
122 }
123
124 void do_DwmFlush()
125 {
126 static HMODULE shell = LoadLibrary("dwmapi.dll");
127
128 if(!shell)
129 return;
130
131 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
132 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
133
134 BOOL enabled;
135 isEnabled(&enabled);
136
137 if(isEnabled)
138 flush();
139 }
140
141 #endif // _WIN32
142
143 83751 bool flash_reduction_enabled(bool check_qr)
144 {
145
4/4
✓ Branch 0 taken 81530 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 81074 times.
✓ Branch 3 taken 83295 times.
83751 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
146 }
147
148 // Dialogue largening
149 void large_dialog(DIALOG *d)
150 {
151 large_dialog(d, 1.5);
152 }
153
154 void large_dialog(DIALOG *d, float RESIZE_AMT)
155 {
156 if(!d[0].d1)
157 {
158 d[0].d1 = 1;
159 int32_t oldwidth = d[0].w;
160 int32_t oldheight = d[0].h;
161 int32_t oldx = d[0].x;
162 int32_t oldy = d[0].y;
163 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
164 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
165 d[0].w = int32_t(d[0].w*RESIZE_AMT);
166 d[0].h = int32_t(d[0].h*RESIZE_AMT);
167
168 for(int32_t i=1; d[i].proc !=NULL; i++)
169 {
170 // Place elements horizontally
171 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
172 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
173
174 if(d[i].proc != d_stringloader)
175 {
176 if(d[i].proc==d_bitmap_proc)
177 {
178 d[i].w *= 2;
179 }
180 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
181 }
182
183 // Place elements vertically
184 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
185 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
186
187 // Vertically resize elements
188 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
189 {
190 d[i].h = int32_t((double)d[i].h*1.5);
191 }
192 else if(d[i].proc == jwin_droplist_proc || d[i].proc == d_joylist_proc)
193 {
194 d[i].y += int32_t((double)d[i].h*0.25);
195 d[i].h = int32_t((double)d[i].h*1.25);
196 }
197 else if(d[i].proc==d_bitmap_proc)
198 {
199 d[i].h *= 2;
200 }
201 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
202
203 // Fix frames
204 if(d[i].proc == jwin_frame_proc)
205 {
206 d[i].x++;
207 d[i].y++;
208 d[i].w-=4;
209 d[i].h-=4;
210 }
211 }
212 }
213
214 for(int32_t i=1; d[i].proc!=NULL; i++)
215 {
216 if(d[i].proc==jwin_slider_proc)
217 continue;
218
219 // Bigger font
220 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc && d[i].proc != d_joylist_proc);
221
222 if(!d[i].dp2 && bigfontproc)
223 {
224 d[i].dp2 = get_zc_font(font_lfont_l);
225 }
226 else if(!bigfontproc)
227 {
228 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
229 }
230
231 // Make checkboxes work
232 if(d[i].proc == jwin_check_proc)
233 d[i].proc = jwin_checkfont_proc;
234 else if(d[i].proc == jwin_radio_proc)
235 d[i].proc = jwin_radiofont_proc;
236 }
237
238 jwin_center_dialog(d);
239 }
240
241
242 /**********************************/
243 /******** System functions ********/
244 /**********************************/
245
246 static char cfg_sect[] = "zeldadx"; //We need to rename this.
247 static char ctrl_sect[] = "Controls";
248 static char sfx_sect[] = "Volume";
249
250 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
251 {
252 return D_O_K;
253 }
254
255 bool is_reserved_key(int c)
256 {
257 switch(c)
258 {
259 case KEY_ESC:
260 return true;
261 }
262 return false;
263 }
264 bool is_reserved_keycombo(int c, int modflag)
265 {
266 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
267 return true;
268 return false;
269 }
270 bool checkcheat(Cheat cheat)
271 {
272 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
273 return true; //Main key pressed
274 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
275 return true; //Alt key pressed
276 return false;
277 }
278 116 void load_default_cheatkeys()
279 {
280 116 memset(cheatkeys, 0, sizeof(cheatkeys));
281 116 cheatkeys[Cheat::Life][0] = KEY_H;
282 116 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
283 116 cheatkeys[Cheat::Magic][0] = KEY_M;
284 116 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
285 116 cheatkeys[Cheat::Rupies][0] = KEY_R;
286 116 cheatkeys[Cheat::Bombs][0] = KEY_B;
287 116 cheatkeys[Cheat::Arrows][0] = KEY_A;
288 116 cheatkeys[Cheat::Clock][0] = KEY_I;
289 116 cheatkeys[Cheat::Walls][0] = KEY_F11;
290 116 cheatkeys[Cheat::Fast][0] = KEY_Q;
291 116 cheatkeys[Cheat::Light][0] = KEY_L;
292 116 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
293 116 cheatkeys[Cheat::Kill][0] = KEY_K;
294 116 cheatkeys[Cheat::GoTo][0] = KEY_G;
295 116 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
296 116 cheatkeys[Cheat::ShowL0][0] = KEY_0;
297 116 cheatkeys[Cheat::ShowL1][0] = KEY_1;
298 116 cheatkeys[Cheat::ShowL2][0] = KEY_2;
299 116 cheatkeys[Cheat::ShowL3][0] = KEY_3;
300 116 cheatkeys[Cheat::ShowL4][0] = KEY_4;
301 116 cheatkeys[Cheat::ShowL5][0] = KEY_5;
302 116 cheatkeys[Cheat::ShowL6][0] = KEY_6;
303 116 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
304 116 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
305 116 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
306 116 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
307 116 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
308 116 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
309 116 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
310 116 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
311 116 }
312 116 void load_game_configs()
313 {
314 116 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
315 116 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
316 116 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
317 116 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
318 116 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
319 116 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
320 116 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
321 116 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
322 116 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
323 116 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
324 116 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
325 116 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
326 116 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
327 116 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
328 116 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
329
330 //cheat modifier keya
331 116 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
332 116 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
333 116 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
334 116 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
335
336 //cheat keys
337 116 load_default_cheatkeys();
338 char buf[256];
339
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 4060 times.
4176 for(size_t q = 1; q < Cheat::Last; ++q)
340 {
341
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 if(!bindable_cheat((Cheat)q)) continue;
342 4060 std::string cheatname = cheat_to_string((Cheat)q);
343
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 util::lowerstr(cheatname);
344 4060 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
345
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
346 4060 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
347
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
348 4060 }
349
350
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
351 joystick_index = 0;
352
353 116 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
354 116 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
355 116 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
356 116 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
357 116 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
358 116 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
359 116 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
360 116 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
361 116 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
362 116 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
363
364 116 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
365 116 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
366 116 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
367 116 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
368
369 116 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
370 116 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
371 116 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
372 116 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
373 116 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
374 116 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
375 116 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
376 116 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
377 116 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
378 116 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
379 116 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
380
381 116 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
382 116 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
383 116 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
384 116 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
385
386 116 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
387
388 116 digi_volume = zc_get_config(sfx_sect,"digi",248);
389 116 midi_volume = zc_get_config(sfx_sect,"midi",255);
390 116 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
391 116 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
392 116 pan_style = zc_get_config(sfx_sect,"pan",1);
393 // 1 <= zcmusic_bufsz <= 128
394 116 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
395 116 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
396 116 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
397 116 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
398 116 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
399 116 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
400 116 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
401 #ifdef __EMSCRIPTEN__
402 if (em_is_mobile()) NameEntryMode = 2;
403 #endif
404 116 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
405 116 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
406 116 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
407 116 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
408 116 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
409
410 //default - scale x2, 640 x 480
411 116 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
412 116 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
413 116 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
414 116 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
415 116 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
416 116 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
417 116 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
418
419 116 loadlast = zc_get_config(cfg_sect,"load_last",0);
420
421 116 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
422
423 116 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
424
425 116 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
426 116 info_opacity = zc_get_config("zc","debug_info_opacity",255);
427 #ifdef _WIN32
428 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
429 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
430 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
431 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
432
433 // This one's for Aero
434 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
435
436 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
437 #else //UNIX
438 116 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
439 116 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
440 116 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
441 #endif
442 116 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
443 116 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
444
445 116 strcpy(qstdir,zc_get_config(cfg_sect,"quest_dir","quests"));
446 116 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
447 116 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
448 116 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
449 116 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
450 116 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
451 116 heart_beep = zc_get_config(cfg_sect,"heart_beep",0)!=0;
452 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
453 116 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
454 116 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
455 116 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
456 116 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
457 116 }
458
459 void save_control_configs(bool kb)
460 {
461 if(kb)
462 {
463 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
464 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
465 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
466 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
467
468 if (!replay_is_replaying())
469 {
470 zc_set_config(ctrl_sect,"key_a",Akey);
471 zc_set_config(ctrl_sect,"key_b",Bkey);
472 zc_set_config(ctrl_sect,"key_s",Skey);
473 zc_set_config(ctrl_sect,"key_l",Lkey);
474 zc_set_config(ctrl_sect,"key_r",Rkey);
475 zc_set_config(ctrl_sect,"key_p",Pkey);
476 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
477 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
478 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
479 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
480 zc_set_config(ctrl_sect,"key_up", DUkey);
481 zc_set_config(ctrl_sect,"key_down", DDkey);
482 zc_set_config(ctrl_sect,"key_left", DLkey);
483 zc_set_config(ctrl_sect,"key_right",DRkey);
484 }
485 }
486 else
487 {
488 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
489 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
490 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
491 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
492 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
493 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
494 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
495 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
496 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
497 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
498 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
499 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
500 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
501 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
502
503 zc_set_config(ctrl_sect,"btn_a",Abtn);
504 zc_set_config(ctrl_sect,"btn_b",Bbtn);
505 zc_set_config(ctrl_sect,"btn_s",Sbtn);
506 zc_set_config(ctrl_sect,"btn_m",Mbtn);
507 zc_set_config(ctrl_sect,"btn_l",Lbtn);
508 zc_set_config(ctrl_sect,"btn_r",Rbtn);
509 zc_set_config(ctrl_sect,"btn_p",Pbtn);
510 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
511 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
512 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
513 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
514
515 zc_set_config(ctrl_sect,"btn_up",DUbtn);
516 zc_set_config(ctrl_sect,"btn_down",DDbtn);
517 zc_set_config(ctrl_sect,"btn_left",DLbtn);
518 zc_set_config(ctrl_sect,"btn_right",DRbtn);
519 }
520 }
521
522 void save_cheatkeys()
523 {
524 char buf[256];
525 for(size_t q = 1; q < Cheat::Last; ++q)
526 {
527 if(!bindable_cheat((Cheat)q)) continue;
528 std::string cheatname = cheat_to_string((Cheat)q);
529 util::lowerstr(cheatname);
530 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
531 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
532 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
533 if(cheatkeys[q][1])
534 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
535 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
536 }
537 }
538
539 void save_game_configs()
540 {
541 packfile_password("");
542
543 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
544
545 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
546 {
547 int o_window_x, o_window_y;
548 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
549 zc_set_config(cfg_sect,"window_x",o_window_x);
550 zc_set_config(cfg_sect,"window_y",o_window_y);
551 }
552
553 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
554 {
555 double monitor_scale = zc_get_monitor_scale();
556 window_width = al_get_display_width(all_get_display()) / monitor_scale;
557 window_height = al_get_display_height(all_get_display()) / monitor_scale;
558 zc_set_config(cfg_sect,"window_width",window_width);
559 zc_set_config(cfg_sect,"window_height",window_height);
560 }
561
562 zc_set_config(cfg_sect,"load_last",loadlast);
563 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
564
565 flush_config_file();
566 #ifdef __EMSCRIPTEN__
567 em_sync_fs();
568 #endif
569 }
570
571 //----------------------------------------------------------------
572
573 // Timers
574
575 28709 void fps_callback()
576 {
577 28709 lastfps=framecnt;
578 28709 framecnt=0;
579 28709 }
580
581 END_OF_FUNCTION(fps_callback)
582
583 116 int32_t Z_init_timers()
584 {
585 static bool didit = false;
586 const static char *err_str = "Couldn't allocate timer";
587 116 err_str = err_str; //Unused variable warning
588
589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(didit)
590 return 1;
591
592 116 didit = true;
593
594 LOCK_VARIABLE(lastfps);
595 LOCK_VARIABLE(framecnt);
596 LOCK_FUNCTION(fps_callback);
597
598
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
599 return 0;
600
601 116 return 1;
602 116 }
603
604 void Z_remove_timers()
605 {
606 remove_int(fps_callback);
607 }
608
609 //----------------------------------------------------------------
610
611 void go()
612 {
613 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
614 }
615
616 void comeback()
617 {
618 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
619 }
620
621 void dump_pal(BITMAP *dest)
622 {
623 for(int32_t i=0; i<256; i++)
624 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
625 }
626
627 //----------------------------------------------------------------
628
629 int game_mouse_index = ZCM_BLANK;
630 static bool system_mouse = false;
631 28 bool sys_mouse()
632 {
633 28 system_mouse = true;
634 28 return MouseSprite::set(ZCM_NORMAL);
635 }
636 559 bool game_mouse()
637 {
638 559 system_mouse = false;
639 559 return MouseSprite::set(game_mouse_index);
640 }
641 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
642 {
643 if(!bmp)
644 return;
645 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
646 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
647 if(bmp->w == scaledw && bmp->h == scaledh)
648 user_scale = false;
649 if(user_scale || sys_recolor)
650 {
651 if(!user_scale) scale = 1;
652 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
653 if(user_scale)
654 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
655 else
656 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
657 if(sys_recolor)
658 recolor_mouse(tmpbmp);
659 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
660 destroy_bitmap(tmpbmp);
661 }
662 else
663 {
664 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
665 }
666 }
667
668 //Handles converting the mouse sprite from the .dat file
669 void recolor_mouse(BITMAP* bmp)
670 {
671 for(int32_t x = 0; x < bmp->w; ++x)
672 {
673 for(int32_t y = 0; y < bmp->h; ++y)
674 {
675 int32_t color = getpixel(bmp, x, y);
676 switch(color)
677 {
678 case dvc(1):
679 color = jwin_pal[jcCURSORMISC];
680 break;
681 case dvc(2):
682 color = jwin_pal[jcCURSOROUTLINE];
683 break;
684 case dvc(3):
685 color = jwin_pal[jcCURSORLIGHT];
686 break;
687 case dvc(5):
688 color = jwin_pal[jcCURSORDARK];
689 break;
690 default:
691 continue;
692 }
693 putpixel(bmp, x, y, color);
694 }
695 }
696 }
697 void load_mouse()
698 {
699 PALETTE pal;
700 BITMAP* cursor_bitmap = load_bitmap("assets/cursor.bmp", pal);
701 if (!cursor_bitmap)
702 Z_error_fatal("Missing required file %s\n", "assets/cursor.bmp");
703
704 enter_sys_pal();
705 MouseSprite::set(-1);
706 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
707 int32_t sz = 16*scale;
708 for(int32_t j = 0; j < 1; ++j)
709 {
710 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
711 if(zcmouse[j])
712 destroy_bitmap(zcmouse[j]);
713 zcmouse[j] = create_bitmap_ex(8,sz,sz);
714 clear_bitmap(zcmouse[j]);
715 clear_bitmap(tmpbmp);
716 blit(cursor_bitmap,tmpbmp,1,j*17+1,0,0,16,16);
717 recolor_mouse(tmpbmp);
718 if(sz!=16)
719 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
720 else
721 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
722 destroy_bitmap(tmpbmp);
723 }
724 if(!hw_palette) hw_palette = &RAMpal;
725 zc_set_palette(*hw_palette);
726
727 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
728 clear_bitmap(blankmouse);
729
730 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
731 MouseSprite::assign(ZCM_BLANK, blankmouse);
732 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
733
734 //Reload the mouse
735 if(system_mouse)
736 sys_mouse();
737 else game_mouse();
738
739 destroy_bitmap(blankmouse);
740 destroy_bitmap(cursor_bitmap);
741 exit_sys_pal();
742 }
743
744 // sets the video mode and initializes the palette and mouse sprite
745 116 bool game_vid_mode(int32_t mode,int32_t wait)
746 {
747
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if (is_headless())
748 116 return true;
749
750 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
751 {
752 return false;
753 }
754
755 scrx = (resx-320)>>1;
756 scry = (resy-240)>>1;
757 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
758 zcmouse[q] = NULL;
759 load_mouse();
760
761 for(int32_t i=240; i<256; i++)
762 RAMpal[i]=pal_gui[i];
763
764 zc_set_palette(RAMpal);
765 clear_to_color(screen,BLACK);
766
767 rest(wait);
768 return true;
769 116 }
770
771 8 void null_quest()
772 {
773 char qstdat_string[2048];
774 8 strcpy(qstdat_string, "modules/classic/default.qst");
775
776 #ifdef __EMSCRIPTEN__
777 // The quest template data file is not included because it's really big and isn't really needed
778 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
779 // which is much smaller.
780 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
781 #endif
782
783 8 byte skip_flags[4] = { 0 };
784
785 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
786 8 }
787
788 8 void init_NES_mode()
789 {
790 8 null_quest();
791 8 }
792
793 //----------------------------------------------------------------
794
795 qword trianglelines[16]=
796 {
797 0x0000000000000000ULL,
798 0xFD00000000000000ULL,
799 0xFDFD000000000000ULL,
800 0xFDFDFD0000000000ULL,
801 0xFDFDFDFD00000000ULL,
802 0xFDFDFDFDFD000000ULL,
803 0xFDFDFDFDFDFD0000ULL,
804 0xFDFDFDFDFDFDFD00ULL,
805 0xFDFDFDFDFDFDFDFDULL,
806 0x00FDFDFDFDFDFDFDULL,
807 0x0000FDFDFDFDFDFDULL,
808 0x000000FDFDFDFDFDULL,
809 0x00000000FDFDFDFDULL,
810 0x0000000000FDFDFDULL,
811 0x000000000000FDFDULL,
812 0x00000000000000FDULL,
813 };
814
815 word screen_triangles[28][32];
816 /*
817 qword triangles[4][16]= //[direction][value]
818 {
819 {
820 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
821 },
822 {
823 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
824 },
825 {
826 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
827 },
828 {
829 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
830 }
831 };
832 */
833
834
835 /*
836 byte triangles[4][16][8]= //[direction][value][line]
837 {
838 {
839 {
840 0, 0, 0, 0, 0, 0, 0, 0
841 },
842 {
843 1, 0, 0, 0, 0, 0, 0, 0
844 },
845 {
846 2, 1, 0, 0, 0, 0, 0, 0
847 },
848 {
849 3, 2, 1, 0, 0, 0, 0, 0
850 },
851 {
852 4, 3, 2, 1, 0, 0, 0, 0
853 },
854 {
855 5, 4, 3, 2, 1, 0, 0, 0
856 },
857 {
858 6, 5, 4, 3, 2, 1, 0, 0
859 },
860 {
861 7, 6, 5, 4, 3, 2, 1, 0
862 },
863 {
864 8, 7, 6, 5, 4, 3, 2, 1
865 },
866 {
867 8, 8, 7, 6, 5, 4, 3, 2
868 },
869 {
870 8, 8, 8, 7, 6, 5, 4, 3
871 },
872 {
873 8, 8, 8, 8, 7, 6, 5, 4
874 },
875 {
876 8, 8, 8, 8, 8, 7, 6, 5
877 },
878 {
879 8, 8, 8, 8, 8, 8, 7, 6
880 },
881 {
882 8, 8, 8, 8, 8, 8, 8, 7
883 },
884 {
885 8, 8, 8, 8, 8, 8, 8, 8
886 }
887 },
888 {
889 {
890 0, 0, 0, 0, 0, 0, 0, 0
891 },
892 {
893 15, 0, 0, 0, 0, 0, 0, 0
894 },
895 {
896 14, 15, 0, 0, 0, 0, 0, 0
897 },
898 {
899 13, 14, 15, 0, 0, 0, 0, 0
900 },
901 {
902 12, 13, 14, 15, 0, 0, 0, 0
903 },
904 {
905 11, 12, 13, 14, 15, 0, 0, 0
906 },
907 {
908 10, 11, 12, 13, 14, 15, 0, 0
909 },
910 {
911 9, 10, 11, 12, 13, 14, 15, 0
912 },
913 {
914 8, 9, 10, 11, 12, 13, 14, 15
915 },
916 {
917 8, 8, 9, 10, 11, 12, 13, 14
918 },
919 {
920 8, 8, 8, 9, 10, 11, 12, 13
921 },
922 {
923 8, 8, 8, 8, 9, 10, 11, 12
924 },
925 {
926 8, 8, 8, 8, 8, 9, 10, 11
927 },
928 {
929 8, 8, 8, 8, 8, 8, 9, 10
930 },
931 {
932 8, 8, 8, 8, 8, 8, 8, 9
933 },
934 {
935 8, 8, 8, 8, 8, 8, 8, 8
936 }
937 },
938 {
939 {
940 0, 0, 0, 0, 0, 0, 0, 0
941 },
942 {
943 0, 0, 0, 0, 0, 0, 0, 1
944 },
945 {
946 0, 0, 0, 0, 0, 0, 1, 2
947 },
948 {
949 0, 0, 0, 0, 0, 1, 2, 3
950 },
951 {
952 0, 0, 0, 0, 1, 2, 3, 4
953 },
954 {
955 0, 0, 0, 1, 2, 3, 4, 5
956 },
957 {
958 0, 0, 1, 2, 3, 4, 5, 6
959 },
960 {
961 0, 1, 2, 3, 4, 5, 6, 7
962 },
963 {
964 1, 2, 3, 4, 5, 6, 7, 8
965 },
966 {
967 2, 3, 4, 5, 6, 7, 8, 8
968 },
969 {
970 3, 4, 5, 6, 7, 8, 8, 8
971 },
972 {
973 4, 5, 6, 7, 8, 8, 8, 8
974 },
975 {
976 5, 6, 7, 8, 8, 8, 8, 8
977 },
978 {
979 6, 7, 8, 8, 8, 8, 8, 8
980 },
981 {
982 7, 8, 8, 8, 8, 8, 8, 8
983 },
984 {
985 8, 8, 8, 8, 8, 8, 8, 8
986 }
987 },
988 {
989 {
990 0, 0, 0, 0, 0, 0, 0, 0
991 },
992 {
993 0, 0, 0, 0, 0, 0, 0, 15
994 },
995 {
996 0, 0, 0, 0, 0, 0, 15, 14
997 },
998 {
999 0, 0, 0, 0, 0, 15, 14, 13
1000 },
1001 {
1002 0, 0, 0, 0, 15, 14, 13, 12
1003 },
1004 {
1005 0, 0, 0, 15, 14, 13, 12, 11
1006 },
1007 {
1008 0, 0, 15, 14, 13, 12, 11, 10
1009 },
1010 {
1011 0, 15, 14, 13, 12, 11, 10, 9
1012 },
1013 {
1014 15, 14, 13, 12, 11, 10, 9, 8
1015 },
1016 {
1017 14, 13, 12, 11, 10, 9, 8, 8
1018 },
1019 {
1020 13, 12, 11, 10, 9, 8, 8, 8
1021 },
1022 {
1023 12, 11, 10, 9, 8, 8, 8, 8
1024 },
1025 {
1026 11, 10, 9, 8, 8, 8, 8, 8
1027 },
1028 {
1029 10, 9, 8, 8, 8, 8, 8, 8
1030 },
1031 {
1032 9, 8, 8, 8, 8, 8, 8, 8
1033 },
1034 {
1035 8, 8, 8, 8, 8, 8, 8, 8
1036 }
1037 }
1038 };
1039 */
1040
1041
1042
1043 /*
1044 for (int32_t blockrow=0; blockrow<30; ++i)
1045 {
1046 for (int32_t linerow=0; linerow<8; ++i)
1047 {
1048 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1049 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1050 {
1051 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1052 ++triangleline;
1053 }
1054 }
1055 }
1056 */
1057
1058 // the ULL suffixes are to prevent this warning:
1059 // warning: integer constant is too large for "int32_t" type
1060
1061 qword triangles[4][16][8]= //[direction][value][line]
1062 {
1063 {
1064 {
1065 0x0000000000000000ULL,
1066 0x0000000000000000ULL,
1067 0x0000000000000000ULL,
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL
1073 },
1074 {
1075 0xFD00000000000000ULL,
1076 0x0000000000000000ULL,
1077 0x0000000000000000ULL,
1078 0x0000000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL
1083 },
1084 {
1085 0xFDFD000000000000ULL,
1086 0xFD00000000000000ULL,
1087 0x0000000000000000ULL,
1088 0x0000000000000000ULL,
1089 0x0000000000000000ULL,
1090 0x0000000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL
1093 },
1094 {
1095 0xFDFDFD0000000000ULL,
1096 0xFDFD000000000000ULL,
1097 0xFD00000000000000ULL,
1098 0x0000000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL
1103 },
1104 {
1105 0xFDFDFDFD00000000ULL,
1106 0xFDFDFD0000000000ULL,
1107 0xFDFD000000000000ULL,
1108 0xFD00000000000000ULL,
1109 0x0000000000000000ULL,
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL
1113 },
1114 {
1115 0xFDFDFDFDFD000000ULL,
1116 0xFDFDFDFD00000000ULL,
1117 0xFDFDFD0000000000ULL,
1118 0xFDFD000000000000ULL,
1119 0xFD00000000000000ULL,
1120 0x0000000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL
1123 },
1124 {
1125 0xFDFDFDFDFDFD0000ULL,
1126 0xFDFDFDFDFD000000ULL,
1127 0xFDFDFDFD00000000ULL,
1128 0xFDFDFD0000000000ULL,
1129 0xFDFD000000000000ULL,
1130 0xFD00000000000000ULL,
1131 0x0000000000000000ULL,
1132 0x0000000000000000ULL
1133 },
1134 {
1135 0xFDFDFDFDFDFDFD00ULL,
1136 0xFDFDFDFDFDFD0000ULL,
1137 0xFDFDFDFDFD000000ULL,
1138 0xFDFDFDFD00000000ULL,
1139 0xFDFDFD0000000000ULL,
1140 0xFDFD000000000000ULL,
1141 0xFD00000000000000ULL,
1142 0x0000000000000000ULL
1143 },
1144 {
1145 0xFDFDFDFDFDFDFDFDULL,
1146 0xFDFDFDFDFDFDFD00ULL,
1147 0xFDFDFDFDFDFD0000ULL,
1148 0xFDFDFDFDFD000000ULL,
1149 0xFDFDFDFD00000000ULL,
1150 0xFDFDFD0000000000ULL,
1151 0xFDFD000000000000ULL,
1152 0xFD00000000000000ULL
1153 },
1154 {
1155 0xFDFDFDFDFDFDFDFDULL,
1156 0xFDFDFDFDFDFDFDFDULL,
1157 0xFDFDFDFDFDFDFD00ULL,
1158 0xFDFDFDFDFDFD0000ULL,
1159 0xFDFDFDFDFD000000ULL,
1160 0xFDFDFDFD00000000ULL,
1161 0xFDFDFD0000000000ULL,
1162 0xFDFD000000000000ULL
1163 },
1164 {
1165 0xFDFDFDFDFDFDFDFDULL,
1166 0xFDFDFDFDFDFDFDFDULL,
1167 0xFDFDFDFDFDFDFDFDULL,
1168 0xFDFDFDFDFDFDFD00ULL,
1169 0xFDFDFDFDFDFD0000ULL,
1170 0xFDFDFDFDFD000000ULL,
1171 0xFDFDFDFD00000000ULL,
1172 0xFDFDFD0000000000ULL
1173 },
1174 {
1175 0xFDFDFDFDFDFDFDFDULL,
1176 0xFDFDFDFDFDFDFDFDULL,
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFD00ULL,
1180 0xFDFDFDFDFDFD0000ULL,
1181 0xFDFDFDFDFD000000ULL,
1182 0xFDFDFDFD00000000ULL
1183 },
1184 {
1185 0xFDFDFDFDFDFDFDFDULL,
1186 0xFDFDFDFDFDFDFDFDULL,
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFD00ULL,
1191 0xFDFDFDFDFDFD0000ULL,
1192 0xFDFDFDFDFD000000ULL
1193 },
1194 {
1195 0xFDFDFDFDFDFDFDFDULL,
1196 0xFDFDFDFDFDFDFDFDULL,
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFD00ULL,
1202 0xFDFDFDFDFDFD0000ULL
1203 },
1204 {
1205 0xFDFDFDFDFDFDFDFDULL,
1206 0xFDFDFDFDFDFDFDFDULL,
1207 0xFDFDFDFDFDFDFDFDULL,
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFD00ULL
1213 },
1214 {
1215 0xFDFDFDFDFDFDFDFDULL,
1216 0xFDFDFDFDFDFDFDFDULL,
1217 0xFDFDFDFDFDFDFDFDULL,
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL
1223 }
1224 },
1225 {
1226 {
1227 0x0000000000000000ULL,
1228 0x0000000000000000ULL,
1229 0x0000000000000000ULL,
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL
1235 },
1236 {
1237 0x00000000000000FDULL,
1238 0x0000000000000000ULL,
1239 0x0000000000000000ULL,
1240 0x0000000000000000ULL,
1241 0x0000000000000000ULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL
1245 },
1246 {
1247 0x000000000000FDFDULL,
1248 0x00000000000000FDULL,
1249 0x0000000000000000ULL,
1250 0x0000000000000000ULL,
1251 0x0000000000000000ULL,
1252 0x0000000000000000ULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL
1255 },
1256 {
1257 0x0000000000FDFDFDULL,
1258 0x000000000000FDFDULL,
1259 0x00000000000000FDULL,
1260 0x0000000000000000ULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL
1265 },
1266 {
1267 0x00000000FDFDFDFDULL,
1268 0x0000000000FDFDFDULL,
1269 0x000000000000FDFDULL,
1270 0x00000000000000FDULL,
1271 0x0000000000000000ULL,
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL
1275 },
1276 {
1277 0x000000FDFDFDFDFDULL,
1278 0x00000000FDFDFDFDULL,
1279 0x0000000000FDFDFDULL,
1280 0x000000000000FDFDULL,
1281 0x00000000000000FDULL,
1282 0x0000000000000000ULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL
1285 },
1286 {
1287 0x0000FDFDFDFDFDFDULL,
1288 0x000000FDFDFDFDFDULL,
1289 0x00000000FDFDFDFDULL,
1290 0x0000000000FDFDFDULL,
1291 0x000000000000FDFDULL,
1292 0x00000000000000FDULL,
1293 0x0000000000000000ULL,
1294 0x0000000000000000ULL
1295 },
1296 {
1297 0x00FDFDFDFDFDFDFDULL,
1298 0x0000FDFDFDFDFDFDULL,
1299 0x000000FDFDFDFDFDULL,
1300 0x00000000FDFDFDFDULL,
1301 0x0000000000FDFDFDULL,
1302 0x000000000000FDFDULL,
1303 0x00000000000000FDULL,
1304 0x0000000000000000ULL
1305 },
1306 {
1307 0xFDFDFDFDFDFDFDFDULL,
1308 0x00FDFDFDFDFDFDFDULL,
1309 0x0000FDFDFDFDFDFDULL,
1310 0x000000FDFDFDFDFDULL,
1311 0x00000000FDFDFDFDULL,
1312 0x0000000000FDFDFDULL,
1313 0x000000000000FDFDULL,
1314 0x00000000000000FDULL
1315 },
1316 {
1317 0xFDFDFDFDFDFDFDFDULL,
1318 0xFDFDFDFDFDFDFDFDULL,
1319 0x00FDFDFDFDFDFDFDULL,
1320 0x0000FDFDFDFDFDFDULL,
1321 0x000000FDFDFDFDFDULL,
1322 0x00000000FDFDFDFDULL,
1323 0x0000000000FDFDFDULL,
1324 0x000000000000FDFDULL
1325 },
1326 {
1327 0xFDFDFDFDFDFDFDFDULL,
1328 0xFDFDFDFDFDFDFDFDULL,
1329 0xFDFDFDFDFDFDFDFDULL,
1330 0x00FDFDFDFDFDFDFDULL,
1331 0x0000FDFDFDFDFDFDULL,
1332 0x000000FDFDFDFDFDULL,
1333 0x00000000FDFDFDFDULL,
1334 0x0000000000FDFDFDULL
1335 },
1336 {
1337 0xFDFDFDFDFDFDFDFDULL,
1338 0xFDFDFDFDFDFDFDFDULL,
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0x00FDFDFDFDFDFDFDULL,
1342 0x0000FDFDFDFDFDFDULL,
1343 0x000000FDFDFDFDFDULL,
1344 0x00000000FDFDFDFDULL
1345 },
1346 {
1347 0xFDFDFDFDFDFDFDFDULL,
1348 0xFDFDFDFDFDFDFDFDULL,
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0x00FDFDFDFDFDFDFDULL,
1353 0x0000FDFDFDFDFDFDULL,
1354 0x000000FDFDFDFDFDULL
1355 },
1356 {
1357 0xFDFDFDFDFDFDFDFDULL,
1358 0xFDFDFDFDFDFDFDFDULL,
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0x00FDFDFDFDFDFDFDULL,
1364 0x0000FDFDFDFDFDFDULL
1365 },
1366 {
1367 0xFDFDFDFDFDFDFDFDULL,
1368 0xFDFDFDFDFDFDFDFDULL,
1369 0xFDFDFDFDFDFDFDFDULL,
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0x00FDFDFDFDFDFDFDULL
1375 },
1376 {
1377 0xFDFDFDFDFDFDFDFDULL,
1378 0xFDFDFDFDFDFDFDFDULL,
1379 0xFDFDFDFDFDFDFDFDULL,
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL
1385 }
1386 },
1387 {
1388 {
1389 0x0000000000000000ULL,
1390 0x0000000000000000ULL,
1391 0x0000000000000000ULL,
1392 0x0000000000000000ULL,
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL
1397 },
1398 {
1399 0x0000000000000000ULL,
1400 0x0000000000000000ULL,
1401 0x0000000000000000ULL,
1402 0x0000000000000000ULL,
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0xFD00000000000000ULL
1407 },
1408 {
1409 0x0000000000000000ULL,
1410 0x0000000000000000ULL,
1411 0x0000000000000000ULL,
1412 0x0000000000000000ULL,
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0xFD00000000000000ULL,
1416 0xFDFD000000000000ULL
1417 },
1418 {
1419 0x0000000000000000ULL,
1420 0x0000000000000000ULL,
1421 0x0000000000000000ULL,
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0xFD00000000000000ULL,
1425 0xFDFD000000000000ULL,
1426 0xFDFDFD0000000000ULL
1427 },
1428 {
1429 0x0000000000000000ULL,
1430 0x0000000000000000ULL,
1431 0x0000000000000000ULL,
1432 0x0000000000000000ULL,
1433 0xFD00000000000000ULL,
1434 0xFDFD000000000000ULL,
1435 0xFDFDFD0000000000ULL,
1436 0xFDFDFDFD00000000ULL
1437 },
1438 {
1439 0x0000000000000000ULL,
1440 0x0000000000000000ULL,
1441 0x0000000000000000ULL,
1442 0xFD00000000000000ULL,
1443 0xFDFD000000000000ULL,
1444 0xFDFDFD0000000000ULL,
1445 0xFDFDFDFD00000000ULL,
1446 0xFDFDFDFDFD000000ULL
1447 },
1448 {
1449 0x0000000000000000ULL,
1450 0x0000000000000000ULL,
1451 0xFD00000000000000ULL,
1452 0xFDFD000000000000ULL,
1453 0xFDFDFD0000000000ULL,
1454 0xFDFDFDFD00000000ULL,
1455 0xFDFDFDFDFD000000ULL,
1456 0xFDFDFDFDFDFD0000ULL
1457 },
1458 {
1459 0x0000000000000000ULL,
1460 0xFD00000000000000ULL,
1461 0xFDFD000000000000ULL,
1462 0xFDFDFD0000000000ULL,
1463 0xFDFDFDFD00000000ULL,
1464 0xFDFDFDFDFD000000ULL,
1465 0xFDFDFDFDFDFD0000ULL,
1466 0xFDFDFDFDFDFDFD00ULL
1467 },
1468 {
1469 0xFD00000000000000ULL,
1470 0xFDFD000000000000ULL,
1471 0xFDFDFD0000000000ULL,
1472 0xFDFDFDFD00000000ULL,
1473 0xFDFDFDFDFD000000ULL,
1474 0xFDFDFDFDFDFD0000ULL,
1475 0xFDFDFDFDFDFDFD00ULL,
1476 0xFDFDFDFDFDFDFDFDULL
1477 },
1478 {
1479 0xFDFD000000000000ULL,
1480 0xFDFDFD0000000000ULL,
1481 0xFDFDFDFD00000000ULL,
1482 0xFDFDFDFDFD000000ULL,
1483 0xFDFDFDFDFDFD0000ULL,
1484 0xFDFDFDFDFDFDFD00ULL,
1485 0xFDFDFDFDFDFDFDFDULL,
1486 0xFDFDFDFDFDFDFDFDULL
1487 },
1488 {
1489 0xFDFDFD0000000000ULL,
1490 0xFDFDFDFD00000000ULL,
1491 0xFDFDFDFDFD000000ULL,
1492 0xFDFDFDFDFDFD0000ULL,
1493 0xFDFDFDFDFDFDFD00ULL,
1494 0xFDFDFDFDFDFDFDFDULL,
1495 0xFDFDFDFDFDFDFDFDULL,
1496 0xFDFDFDFDFDFDFDFDULL
1497 },
1498 {
1499 0xFDFDFDFD00000000ULL,
1500 0xFDFDFDFDFD000000ULL,
1501 0xFDFDFDFDFDFD0000ULL,
1502 0xFDFDFDFDFDFDFD00ULL,
1503 0xFDFDFDFDFDFDFDFDULL,
1504 0xFDFDFDFDFDFDFDFDULL,
1505 0xFDFDFDFDFDFDFDFDULL,
1506 0xFDFDFDFDFDFDFDFDULL
1507 },
1508 {
1509 0xFDFDFDFDFD000000ULL,
1510 0xFDFDFDFDFDFD0000ULL,
1511 0xFDFDFDFDFDFDFD00ULL,
1512 0xFDFDFDFDFDFDFDFDULL,
1513 0xFDFDFDFDFDFDFDFDULL,
1514 0xFDFDFDFDFDFDFDFDULL,
1515 0xFDFDFDFDFDFDFDFDULL,
1516 0xFDFDFDFDFDFDFDFDULL
1517 },
1518 {
1519 0xFDFDFDFDFDFD0000ULL,
1520 0xFDFDFDFDFDFDFD00ULL,
1521 0xFDFDFDFDFDFDFDFDULL,
1522 0xFDFDFDFDFDFDFDFDULL,
1523 0xFDFDFDFDFDFDFDFDULL,
1524 0xFDFDFDFDFDFDFDFDULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL
1527 },
1528 {
1529 0xFDFDFDFDFDFDFD00ULL,
1530 0xFDFDFDFDFDFDFDFDULL,
1531 0xFDFDFDFDFDFDFDFDULL,
1532 0xFDFDFDFDFDFDFDFDULL,
1533 0xFDFDFDFDFDFDFDFDULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL
1537 },
1538 {
1539 0xFDFDFDFDFDFDFDFDULL,
1540 0xFDFDFDFDFDFDFDFDULL,
1541 0xFDFDFDFDFDFDFDFDULL,
1542 0xFDFDFDFDFDFDFDFDULL,
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL
1547 }
1548 },
1549 {
1550 {
1551 0x0000000000000000ULL,
1552 0x0000000000000000ULL,
1553 0x0000000000000000ULL,
1554 0x0000000000000000ULL,
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL
1559 },
1560 {
1561 0x0000000000000000ULL,
1562 0x0000000000000000ULL,
1563 0x0000000000000000ULL,
1564 0x0000000000000000ULL,
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x00000000000000FDULL
1569 },
1570 {
1571 0x0000000000000000ULL,
1572 0x0000000000000000ULL,
1573 0x0000000000000000ULL,
1574 0x0000000000000000ULL,
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x00000000000000FDULL,
1578 0x000000000000FDFDULL
1579 },
1580 {
1581 0x0000000000000000ULL,
1582 0x0000000000000000ULL,
1583 0x0000000000000000ULL,
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x00000000000000FDULL,
1587 0x000000000000FDFDULL,
1588 0x0000000000FDFDFDULL
1589 },
1590 {
1591 0x0000000000000000ULL,
1592 0x0000000000000000ULL,
1593 0x0000000000000000ULL,
1594 0x0000000000000000ULL,
1595 0x00000000000000FDULL,
1596 0x000000000000FDFDULL,
1597 0x0000000000FDFDFDULL,
1598 0x00000000FDFDFDFDULL
1599 },
1600 {
1601 0x0000000000000000ULL,
1602 0x0000000000000000ULL,
1603 0x0000000000000000ULL,
1604 0x00000000000000FDULL,
1605 0x000000000000FDFDULL,
1606 0x0000000000FDFDFDULL,
1607 0x00000000FDFDFDFDULL,
1608 0x000000FDFDFDFDFDULL
1609 },
1610 {
1611 0x0000000000000000ULL,
1612 0x0000000000000000ULL,
1613 0x00000000000000FDULL,
1614 0x000000000000FDFDULL,
1615 0x0000000000FDFDFDULL,
1616 0x00000000FDFDFDFDULL,
1617 0x000000FDFDFDFDFDULL,
1618 0x0000FDFDFDFDFDFDULL
1619 },
1620 {
1621 0x0000000000000000ULL,
1622 0x00000000000000FDULL,
1623 0x000000000000FDFDULL,
1624 0x0000000000FDFDFDULL,
1625 0x00000000FDFDFDFDULL,
1626 0x000000FDFDFDFDFDULL,
1627 0x0000FDFDFDFDFDFDULL,
1628 0x00FDFDFDFDFDFDFDULL
1629 },
1630 {
1631 0x00000000000000FDULL,
1632 0x000000000000FDFDULL,
1633 0x0000000000FDFDFDULL,
1634 0x00000000FDFDFDFDULL,
1635 0x000000FDFDFDFDFDULL,
1636 0x0000FDFDFDFDFDFDULL,
1637 0x00FDFDFDFDFDFDFDULL,
1638 0xFDFDFDFDFDFDFDFDULL
1639 },
1640 {
1641 0x000000000000FDFDULL,
1642 0x0000000000FDFDFDULL,
1643 0x00000000FDFDFDFDULL,
1644 0x000000FDFDFDFDFDULL,
1645 0x0000FDFDFDFDFDFDULL,
1646 0x00FDFDFDFDFDFDFDULL,
1647 0xFDFDFDFDFDFDFDFDULL,
1648 0xFDFDFDFDFDFDFDFDULL
1649 },
1650 {
1651 0x0000000000FDFDFDULL,
1652 0x00000000FDFDFDFDULL,
1653 0x000000FDFDFDFDFDULL,
1654 0x0000FDFDFDFDFDFDULL,
1655 0x00FDFDFDFDFDFDFDULL,
1656 0xFDFDFDFDFDFDFDFDULL,
1657 0xFDFDFDFDFDFDFDFDULL,
1658 0xFDFDFDFDFDFDFDFDULL
1659 },
1660 {
1661 0x00000000FDFDFDFDULL,
1662 0x000000FDFDFDFDFDULL,
1663 0x0000FDFDFDFDFDFDULL,
1664 0x00FDFDFDFDFDFDFDULL,
1665 0xFDFDFDFDFDFDFDFDULL,
1666 0xFDFDFDFDFDFDFDFDULL,
1667 0xFDFDFDFDFDFDFDFDULL,
1668 0xFDFDFDFDFDFDFDFDULL
1669 },
1670 {
1671 0x000000FDFDFDFDFDULL,
1672 0x0000FDFDFDFDFDFDULL,
1673 0x00FDFDFDFDFDFDFDULL,
1674 0xFDFDFDFDFDFDFDFDULL,
1675 0xFDFDFDFDFDFDFDFDULL,
1676 0xFDFDFDFDFDFDFDFDULL,
1677 0xFDFDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL
1679 },
1680 {
1681 0x0000FDFDFDFDFDFDULL,
1682 0x00FDFDFDFDFDFDFDULL,
1683 0xFDFDFDFDFDFDFDFDULL,
1684 0xFDFDFDFDFDFDFDFDULL,
1685 0xFDFDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL
1689 },
1690 {
1691 0x00FDFDFDFDFDFDFDULL,
1692 0xFDFDFDFDFDFDFDFDULL,
1693 0xFDFDFDFDFDFDFDFDULL,
1694 0xFDFDFDFDFDFDFDFDULL,
1695 0xFDFDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL
1699 },
1700 {
1701 0xFDFDFDFDFDFDFDFDULL,
1702 0xFDFDFDFDFDFDFDFDULL,
1703 0xFDFDFDFDFDFDFDFDULL,
1704 0xFDFDFDFDFDFDFDFDULL,
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL
1709 }
1710 }
1711 };
1712
1713 int32_t black_opening_count=0;
1714 int32_t black_opening_x,black_opening_y;
1715 int32_t black_opening_shape;
1716
1717 1507 int32_t choose_opening_shape()
1718 {
1719 // First, count how many bits are set
1720 1507 int32_t numBits=0;
1721 int32_t bitCounter;
1722
1723
2/2
✓ Branch 0 taken 7535 times.
✓ Branch 1 taken 1507 times.
9042 for(int32_t i=0; i<bosMAX; i++)
1724 {
1725
2/2
✓ Branch 0 taken 5812 times.
✓ Branch 1 taken 1723 times.
7535 if(COOLSCROLL&(1<<i))
1726 1723 numBits++;
1727 7535 }
1728
1729 // Shouldn't happen...
1730
1/2
✓ Branch 0 taken 1507 times.
✗ Branch 1 not taken.
1507 if(numBits==0)
1731 return bosCIRCLE;
1732
1733 // Pick a bit
1734 1507 bitCounter=zc_rand()%numBits+1;
1735
1736
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 26 times.
2018 for(int32_t i=0; i<bosMAX; i++)
1737 {
1738 // If this bit is set, decrement the bit counter
1739
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 1637 times.
1992 if(COOLSCROLL&(1<<i))
1740 1637 bitCounter--;
1741
1742 // When the counter hits 0, return a value based on
1743 // which bit it stopped on.
1744 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1745
2/2
✓ Branch 0 taken 1481 times.
✓ Branch 1 taken 511 times.
1992 if(bitCounter==0)
1746 1481 return i;
1747 511 }
1748
1749 // Shouldn't be necessary, but the compiler might complain, at least
1750 26 return bosCIRCLE;
1751 1507 }
1752
1753 396 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1754 {
1755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1756
1757 396 int32_t w=256, h=224;
1758 396 int32_t blockrows=28, blockcolumns=32;
1759 396 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1760
1761
2/2
✓ Branch 0 taken 11088 times.
✓ Branch 1 taken 396 times.
11484 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1762 {
1763
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 11088 times.
365904 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1764 {
1765
2/2
✓ Branch 0 taken 147229 times.
✓ Branch 1 taken 207587 times.
354816 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1766 354816 }
1767 11088 }
1768
1769 396 black_opening_count = 66;
1770 396 black_opening_x = x;
1771 396 black_opening_y = y;
1772 396 lensclk = 0;
1773 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1774
1775
1776
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(black_opening_shape == bosFADEBLACK)
1777 {
1778 refreshTints();
1779 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1780 }
1781
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(wait)
1782 {
1783 FFCore.warpScriptCheck();
1784 for(int32_t i=0; i<66; i++)
1785 {
1786 draw_screen(tmpscr);
1787 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1788 advanceframe(true);
1789
1790 if(Quit)
1791 {
1792 break;
1793 }
1794 }
1795 }
1796 396 }
1797
1798 1111 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1799 {
1800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1111 times.
1111 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1801
1802 1111 int32_t w=256, h=224;
1803 1111 int32_t blockrows=28, blockcolumns=32;
1804 1111 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1805
1806
2/2
✓ Branch 0 taken 31108 times.
✓ Branch 1 taken 1111 times.
32219 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1807 {
1808
2/2
✓ Branch 0 taken 995456 times.
✓ Branch 1 taken 31108 times.
1026564 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1809 {
1810
2/2
✓ Branch 0 taken 506828 times.
✓ Branch 1 taken 488628 times.
995456 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1811 995456 }
1812 31108 }
1813
1814 1111 black_opening_count = -66;
1815 1111 black_opening_x = x;
1816 1111 black_opening_y = y;
1817 1111 lensclk = 0;
1818
1/2
✓ Branch 0 taken 1111 times.
✗ Branch 1 not taken.
1111 if(black_opening_shape == bosFADEBLACK)
1819 {
1820 refreshTints();
1821 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1822 }
1823
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 912 times.
1111 if(wait)
1824 {
1825 912 FFCore.warpScriptCheck();
1826
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 60192 times.
61104 for(int32_t i=0; i<66; i++)
1827 {
1828 60192 draw_screen(tmpscr);
1829 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1830 60192 advanceframe(true);
1831
1832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60192 times.
60192 if(Quit)
1833 {
1834 break;
1835 }
1836 60192 }
1837 912 }
1838 1111 }
1839
1840 99462 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1841 {
1842 99462 clear_to_color(tmp_scr,BLACK);
1843 99462 int32_t w=256, h=224;
1844
1845
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 7656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90288 times.
99462 switch(black_opening_shape)
1846 {
1847 case bosOVAL:
1848 {
1849 858 double new_w=(w/2)+abs(w/2-x);
1850 858 double new_h=(h/2)+abs(h/2-y);
1851 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1852 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1853 858 break;
1854 }
1855
1856 case bosTRIANGLE:
1857 {
1858 660 double new_w=(w/2)+abs(w/2-x);
1859 660 double new_h=(h/2)+abs(h/2-y);
1860 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1861 660 double P2= (PI/2);
1862 660 double P23=(2*PI/3);
1863 660 double P43=(4*PI/3);
1864 660 double Pa= (-4*PI*a/(3*max_a));
1865 660 double angle=P2+Pa;
1866 660 double a0=angle;
1867 660 double a2=angle+P23;
1868 660 double a4=angle+P43;
1869 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1870 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1871 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1872 0);
1873 660 break;
1874 }
1875
1876 case bosSMAS:
1877 {
1878
2/2
✓ Branch 0 taken 4158 times.
✓ Branch 1 taken 3498 times.
7656 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1879
1880
2/2
✓ Branch 0 taken 214368 times.
✓ Branch 1 taken 7656 times.
222024 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1881 {
1882
2/2
✓ Branch 0 taken 1714944 times.
✓ Branch 1 taken 214368 times.
1929312 for(int32_t linerow=0; linerow<8; ++linerow)
1883 {
1884 1714944 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1885
1886
2/2
✓ Branch 0 taken 54878208 times.
✓ Branch 1 taken 1714944 times.
56593152 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1887 {
1888 164634624 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1889
6/6
✓ Branch 0 taken 39546648 times.
✓ Branch 1 taken 15331560 times.
✓ Branch 2 taken 35934032 times.
✓ Branch 3 taken 18944176 times.
✓ Branch 4 taken 20602472 times.
✓ Branch 5 taken 15331560 times.
54878208 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1890 54878208 [linerow];
1891 54878208 ++triangleline;
1892
1893
2/2
✓ Branch 0 taken 48018432 times.
✓ Branch 1 taken 6859776 times.
54878208 if(linerow==0)
1894 {
1895 6859776 }
1896 54878208 }
1897 1714944 }
1898 214368 }
1899
1900 7656 break;
1901 }
1902
1903 case bosFADEBLACK:
1904 {
1905 if(black_opening_count<0)
1906 {
1907 black_fade(zc_min(-black_opening_count,63));
1908 }
1909 else if(black_opening_count>0)
1910 {
1911 black_fade(63-zc_max(black_opening_count-3,0));
1912 }
1913 else black_fade(0);
1914 return; //no blitting from tmp_scr!
1915 }
1916
1917 90288 case bosCIRCLE:
1918 default:
1919 {
1920 90288 double new_w=(w/2)+abs(w/2-x);
1921 90288 double new_h=(h/2)+abs(h/2-y);
1922 90288 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1923 //circlefill(tmp_scr,x,y,a<<3,0);
1924 90288 circlefill(tmp_scr,x,y,r,0);
1925 90288 break;
1926 }
1927 }
1928
1929 99462 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1930 99462 }
1931
1932
1933 void black_fade(int32_t fadeamnt)
1934 {
1935 for(int32_t i=0; i < 0xEF; i++)
1936 {
1937 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1938 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1939 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1940 }
1941
1942 refreshpal = true;
1943 }
1944
1945 //----------------------------------------------------------------
1946
1947 44453035 bool item_disabled(int32_t item) //is this item disabled?
1948 {
1949
2/2
✓ Branch 0 taken 1796436 times.
✓ Branch 1 taken 42656599 times.
44453035 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1950 }
1951
1952 7617843 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1953 {
1954
2/2
✓ Branch 0 taken 135248 times.
✓ Branch 1 taken 7482595 times.
7617843 if(current_item(item_type, true) >=item)
1955 {
1956 135248 return true;
1957 }
1958
1959 7482595 return false;
1960 7617843 }
1961
1962 31051977 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1963 {
1964
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6053367 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3220277 times.
✓ Branch 6 taken 16169148 times.
✓ Branch 7 taken 5493498 times.
✓ Branch 8 taken 115687 times.
31051977 switch(item_type)
1965 {
1966 case itype_bomb:
1967 case itype_sbomb:
1968 {
1969 int32_t itemid = getItemID(itemsbuf, item_type, it);
1970
1971 if(itemid == -1)
1972 return false;
1973
1974 return (game->get_item(itemid));
1975 }
1976
1977 case itype_clock:
1978 {
1979 6053367 int32_t itemid = getItemID(itemsbuf, item_type, it);
1980
1981
2/4
✓ Branch 0 taken 6053367 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6053367 times.
✗ Branch 3 not taken.
6053367 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1982 return (game->get_item(itemid));
1983 6053367 return Hero.getClock()?1:0;
1984 }
1985
1986 case itype_key:
1987 return (game->get_keys()>0);
1988
1989 case itype_magiccontainer:
1990 return (game->get_maxmagic()>=game->get_mp_per_block());
1991
1992 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1993 {
1994
1/3
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3220277 switch(it)
1995 {
1996 case -2:
1997 {
1998 for(int32_t i=0; i<MAXLEVELS; i++)
1999 {
2000 if(game->lvlitems[i]&liTRIFORCE)
2001 {
2002 return true;
2003 }
2004 }
2005
2006 return false;
2007 }
2008
2009 case -1:
2010 return (game->lvlitems[dlevel]&liTRIFORCE);
2011
2012 default:
2013
2/4
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3220277 times.
3220277 if(it>=0&&it<MAXLEVELS)
2014 {
2015 3220277 return (game->lvlitems[it]&liTRIFORCE);
2016 }
2017
2018 break;
2019 }
2020
2021 return 0;
2022 }
2023
2024 case itype_map: //it: -2=any, -1=current level, other=that level
2025 {
2026
1/3
✓ Branch 0 taken 16169148 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
16169148 switch(it)
2027 {
2028 case -2:
2029 {
2030 for(int32_t i=0; i<MAXLEVELS; i++)
2031 {
2032 if(game->lvlitems[i]&liMAP)
2033 {
2034 return true;
2035 }
2036 }
2037
2038 return false;
2039 }
2040
2041 case -1:
2042 return (game->lvlitems[dlevel]&liMAP)!=0;
2043
2044 default:
2045
2/4
✓ Branch 0 taken 16169148 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16169148 times.
16169148 if(it>=0&&it<MAXLEVELS)
2046 {
2047 16169148 return (game->lvlitems[it]&liMAP)!=0;
2048 }
2049
2050 break;
2051 }
2052
2053 return 0;
2054 }
2055
2056 case itype_compass: //it: -2=any, -1=current level, other=that level
2057 {
2058
1/3
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5493498 switch(it)
2059 {
2060 case -2:
2061 {
2062 for(int32_t i=0; i<MAXLEVELS; i++)
2063 {
2064 if(game->lvlitems[i]&liCOMPASS)
2065 {
2066 return true;
2067 }
2068 }
2069
2070 return false;
2071 }
2072
2073 case -1:
2074 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2075
2076 default:
2077
2/4
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5493498 times.
✗ Branch 3 not taken.
5493498 if(it>=0&&it<MAXLEVELS)
2078 {
2079 5493498 return (game->lvlitems[it]&liCOMPASS)!=0;
2080 }
2081
2082 break;
2083 }
2084 return 0;
2085 }
2086
2087 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2088 {
2089
1/3
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
115687 switch(it)
2090 {
2091 case -2:
2092 {
2093 for(int32_t i=0; i<MAXLEVELS; i++)
2094 {
2095 if(game->lvlitems[i]&liBOSSKEY)
2096 {
2097 return true;
2098 }
2099 }
2100
2101 return false;
2102 }
2103
2104 case -1:
2105 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2106
2107 default:
2108
2/4
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115687 times.
115687 if(it>=0&&it<MAXLEVELS)
2109 {
2110 115687 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2111 }
2112 break;
2113 }
2114 return 0;
2115 }
2116
2117 default:
2118 //it=(1<<(it-1));
2119 /*if (item_type>=itype_max)
2120 {
2121 enter_sys_pal();
2122 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2123 exit_sys_pal();
2124
2125 return false;
2126 }*/
2127 int32_t itemid = getItemID(itemsbuf, item_type, it);
2128
2129 if(itemid == -1)
2130 return false;
2131
2132 return game->get_item(itemid);
2133 }
2134 31051977 }
2135
2136
2137 100013996 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2138 {
2139
9/9
✓ Branch 0 taken 6053367 times.
✓ Branch 1 taken 51587060 times.
✓ Branch 2 taken 6053367 times.
✓ Branch 3 taken 6053367 times.
✓ Branch 4 taken 6053367 times.
✓ Branch 5 taken 6053367 times.
✓ Branch 6 taken 6053367 times.
✓ Branch 7 taken 6053367 times.
✓ Branch 8 taken 6053367 times.
100013996 switch(item_type)
2140 {
2141 case itype_clock:
2142 {
2143 6053367 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2144
2145
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6053367 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6053367 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2146 return itemsbuf[maxid].fam_type;
2147
2148 6053367 return has_item(itype_clock,1) ? 1 : 0;
2149 }
2150
2151 case itype_key:
2152 6053367 return game->get_keys();
2153
2154 case itype_lkey:
2155 6053367 return game->lvlkeys[get_dlevel()];
2156
2157 case itype_magiccontainer:
2158 6053367 return game->get_maxmagic()/game->get_mp_per_block();
2159
2160 case itype_triforcepiece:
2161 {
2162 6053367 int32_t count=0;
2163
2164
2/2
✓ Branch 0 taken 3099323904 times.
✓ Branch 1 taken 6053367 times.
3105377271 for(int32_t i=0; i<MAXLEVELS; i++)
2165 {
2166 3099323904 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2167 3099323904 }
2168
2169 6053367 return count;
2170 }
2171
2172 case itype_map:
2173 {
2174 6053367 int32_t count=0;
2175
2176
2/2
✓ Branch 0 taken 3099323904 times.
✓ Branch 1 taken 6053367 times.
3105377271 for(int32_t i=0; i<MAXLEVELS; i++)
2177 {
2178 3099323904 count+=(game->lvlitems[i]&liMAP)?1:0;
2179 3099323904 }
2180
2181 6053367 return count;
2182 }
2183
2184 case itype_compass:
2185 {
2186 6053367 int32_t count=0;
2187
2188
2/2
✓ Branch 0 taken 3099323904 times.
✓ Branch 1 taken 6053367 times.
3105377271 for(int32_t i=0; i<MAXLEVELS; i++)
2189 {
2190 3099323904 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2191 3099323904 }
2192
2193 6053367 return count;
2194 }
2195
2196 case itype_bosskey:
2197 {
2198 6053367 int32_t count=0;
2199
2200
2/2
✓ Branch 0 taken 3099323904 times.
✓ Branch 1 taken 6053367 times.
3105377271 for(int32_t i=0; i<MAXLEVELS; i++)
2201 {
2202 3099323904 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2203 3099323904 }
2204
2205 6053367 return count;
2206 }
2207
2208 default:
2209 51587060 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2210
2211
2/2
✓ Branch 0 taken 9875888 times.
✓ Branch 1 taken 41711172 times.
51587060 if(maxid == -1)
2212 41711172 return 0;
2213
2214 9875888 return itemsbuf[maxid].fam_type;
2215 }
2216 100013996 }
2217
2218 92396153 int32_t current_item(int32_t item_type) //item currently being used
2219 {
2220 92396153 return current_item(item_type, true);
2221 }
2222
2223 116 std::map<int32_t, int32_t> itemcache;
2224 116 std::map<int32_t, int32_t> itemcache_cost;
2225
2226 void removeFromItemCache(int32_t itemclass)
2227 {
2228 itemcache.erase(itemclass);
2229 itemcache_cost.erase(itemclass);
2230 }
2231
2232 5857125 void flushItemCache(bool justcost)
2233 {
2234 5857125 itemcache_cost.clear();
2235
2/2
✓ Branch 0 taken 5827094 times.
✓ Branch 1 taken 30031 times.
5857125 if(!justcost)
2236 30031 itemcache.clear();
2237
2/2
✓ Branch 0 taken 5826995 times.
✓ Branch 1 taken 99 times.
5827094 else if(replay_version_check(0,19))
2238 5826995 return;
2239
2240 //also fix the active subscreen if items were deleted -DD
2241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30130 times.
30130 if(game != NULL)
2242 {
2243 30130 verifyBothWeapons();
2244 30130 refresh_subscr_items();
2245 30130 }
2246 5857125 }
2247
2248 // This is used often, so it should be as direct as possible.
2249 3376275283 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2250 {
2251 3376275283 bool use_cost_cache = replay_version_check(19);
2252
2/2
✓ Branch 0 taken 3300715799 times.
✓ Branch 1 taken 75559484 times.
3376275283 if(jinx_check)
2253 {
2254
4/4
✓ Branch 0 taken 47353138 times.
✓ Branch 1 taken 28206346 times.
✓ Branch 2 taken 8273866 times.
✓ Branch 3 taken 39079272 times.
75559484 if(!(HeroSwordClk() || HeroItemClk()))
2255 39079272 jinx_check = false; //not jinxed
2256 75559484 }
2257
2/2
✓ Branch 0 taken 1047446 times.
✓ Branch 1 taken 3375227837 times.
3376275283 if(!Hero.BunnyClock())
2258 3375227837 check_bunny = false; //not bunnied
2259
2/2
✓ Branch 0 taken 3346668553 times.
✓ Branch 1 taken 29606730 times.
3376275283 if(itemtype == itype_ring) checkmagic = true;
2260
4/4
✓ Branch 0 taken 3339795071 times.
✓ Branch 1 taken 36480212 times.
✓ Branch 2 taken 3308449248 times.
✓ Branch 3 taken 29257707 times.
6713982238 if (!jinx_check && !check_bunny
2261
3/4
✓ Branch 0 taken 3339795071 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3337706955 times.
✓ Branch 3 taken 2088116 times.
3339795071 && (use_cost_cache || itemtype != itype_ring))
2262 {
2263
4/4
✓ Branch 0 taken 185316049 times.
✓ Branch 1 taken 3125221315 times.
✓ Branch 2 taken 185129738 times.
✓ Branch 3 taken 186311 times.
3310537364 auto& cache = checkmagic && use_cost_cache ? itemcache_cost : itemcache;
2264 3310537364 auto res = cache.find(itemtype);
2265
2266
2/2
✓ Branch 0 taken 3295211154 times.
✓ Branch 1 taken 15326210 times.
3310537364 if(res != cache.end())
2267 3295211154 return res->second;
2268 15326210 }
2269
2270 81064129 int32_t result = -1;
2271 81064129 int32_t highestlevel = -1;
2272
2273
2/2
✓ Branch 0 taken 20752417024 times.
✓ Branch 1 taken 81064129 times.
20833481153 for(int32_t i=0; i<MAXITEMS; i++)
2274 {
2275
5/6
✓ Branch 0 taken 1522409134 times.
✓ Branch 1 taken 19230007890 times.
✓ Branch 2 taken 21890838 times.
✓ Branch 3 taken 1500518296 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21890838 times.
20752417024 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2276 {
2277
4/4
✓ Branch 0 taken 20046811 times.
✓ Branch 1 taken 1844027 times.
✓ Branch 2 taken 8694 times.
✓ Branch 3 taken 20038117 times.
21890838 if(checkmagic && itemtype != itype_magicring)
2278
2/2
✓ Branch 0 taken 20037947 times.
✓ Branch 1 taken 170 times.
20038117 if(!checkmagiccost(i))
2279 170 continue;
2280
6/6
✓ Branch 0 taken 18598411 times.
✓ Branch 1 taken 3292257 times.
✓ Branch 2 taken 243036 times.
✓ Branch 3 taken 3049221 times.
✓ Branch 4 taken 1846133 times.
✓ Branch 5 taken 1446124 times.
21890668 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1446124 times.
1446124 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2282 1446124 continue;
2283
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20444544 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20444544 if(check_bunny && !checkbunny(i))
2284 continue;
2285
2286
2/2
✓ Branch 0 taken 280132 times.
✓ Branch 1 taken 20164412 times.
20444544 if(itemsbuf[i].fam_type >= highestlevel)
2287 {
2288 20164412 highestlevel = itemsbuf[i].fam_type;
2289 20164412 result=i;
2290 20164412 }
2291 20444544 }
2292 20750970730 }
2293
2294
3/4
✓ Branch 0 taken 44583917 times.
✓ Branch 1 taken 36480212 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44583917 times.
81064129 if(!(jinx_check || check_bunny)) //Can't cache jinx_check/check_bunny
2295 {
2296
2/2
✓ Branch 0 taken 2514 times.
✓ Branch 1 taken 44581403 times.
44583917 if (use_cost_cache)
2297 {
2298
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 1620 times.
2514 if (!checkmagic)
2299 1620 itemcache[itemtype] = result;
2300
5/6
✓ Branch 0 taken 1620 times.
✓ Branch 1 taken 894 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1617 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
2514 if (checkmagic || result < 0 || checkmagiccost(result))
2301 2514 itemcache_cost[itemtype] = result;
2302 2514 }
2303 else
2304 {
2305 44581403 itemcache[itemtype] = result;
2306 }
2307 44583917 }
2308 81064129 return result;
2309 3376275283 }
2310
2311 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2312 3340239284 int32_t current_item_id(int32_t itype, bool checkmagic, bool jinx_check, bool check_bunny)
2313 {
2314
2/4
✓ Branch 0 taken 3340239284 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3340239284 times.
3340239284 if(itype < 0 || itype >= itype_max) return -1;
2315
1/2
✓ Branch 0 taken 3340239284 times.
✗ Branch 1 not taken.
3340239284 if(game->OverrideItems[itype] > -2)
2316 {
2317 auto ovid = game->OverrideItems[itype];
2318 if(ovid < 0 || ovid >= MAXITEMS)
2319 return -1;
2320 if(itemsbuf[ovid].family == itype)
2321 {
2322 if(itype == itype_magicring)
2323 checkmagic = false;
2324 else if(itype == itype_ring)
2325 checkmagic = true;
2326
2327 if(checkmagic && !checkmagiccost(ovid))
2328 return -1;
2329 if(jinx_check && !(itemsbuf[ovid].flags & ITEM_JINX_IMMUNE)
2330 && (usesSwordJinx(ovid) ? HeroSwordClk() : HeroItemClk()))
2331 return -1;
2332 return ovid;
2333 }
2334 }
2335 3340239284 auto ret = _c_item_id_internal(itype,checkmagic,jinx_check,check_bunny);
2336
2/2
✓ Branch 0 taken 39523485 times.
✓ Branch 1 taken 3300715799 times.
3340239284 if(!jinx_check) //If not already a jinx-immune-only check...
2337 {
2338 //And the player IS jinxed...
2339
4/4
✓ Branch 0 taken 3272852430 times.
✓ Branch 1 taken 27863369 times.
✓ Branch 2 taken 8172630 times.
✓ Branch 3 taken 3264679800 times.
3300715799 if(HeroSwordClk() || HeroItemClk())
2340 {
2341 //Then do a jinx-immune-only check here
2342 36035999 auto ret2 = _c_item_id_internal(itype,checkmagic,true,check_bunny);
2343 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2344 //Should NOT need a compat rule, as this should always return -1 in old quests.
2345
2/2
✓ Branch 0 taken 1261308 times.
✓ Branch 1 taken 34774691 times.
36035999 if(ret2 > -1) return ret2;
2346 34774691 }
2347 3299454491 }
2348 3338977976 return ret;
2349 3340239284 }
2350
2351 19333396 int32_t current_item_power(int32_t itemtype)
2352 {
2353 19333396 int32_t result = current_item_id(itemtype,true);
2354
2/2
✓ Branch 0 taken 14040642 times.
✓ Branch 1 taken 5292754 times.
19333396 return (result<0) ? 0 : itemsbuf[result].power;
2355 }
2356
2357 11 int32_t heart_container_id()
2358 {
2359
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 for(int32_t i=0; i<MAXITEMS; i++)
2360 {
2361
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 308 times.
319 if(itemsbuf[i].family == itype_heartcontainer)
2362 {
2363 11 return i;
2364 }
2365 308 }
2366 return -1;
2367 11 }
2368
2369 6053367 int32_t item_tile_mod()
2370 {
2371 6053367 int32_t tile=0;
2372
2373
2/2
✓ Branch 0 taken 1206356 times.
✓ Branch 1 taken 4847011 times.
6053367 if(game->get_bombs())
2374 {
2375 4847011 int32_t itemid = current_item_id(itype_bomb,false);
2376
3/4
✓ Branch 0 taken 4681842 times.
✓ Branch 1 taken 165169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4681842 times.
4847011 if(itemid > -1 && checkbunny(itemid))
2377 4681842 tile+=itemsbuf[itemid].ltm;
2378 4847011 }
2379
2380
2/2
✓ Branch 0 taken 4539291 times.
✓ Branch 1 taken 1514076 times.
6053367 if(game->get_sbombs())
2381 {
2382 1514076 int32_t itemid = current_item_id(itype_sbomb,false);
2383
3/4
✓ Branch 0 taken 1512648 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1512648 times.
1514076 if(itemid > -1 && checkbunny(itemid))
2384 1512648 tile+=itemsbuf[itemid].ltm;
2385 1514076 }
2386
2387
2/2
✓ Branch 0 taken 5943667 times.
✓ Branch 1 taken 109700 times.
6053367 if(current_item(itype_clock))
2388 {
2389 109700 int32_t itemid =
2390
1/2
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
109700 get_qr(qr_HARDCODED_LITEM_LTMS)
2391 ? iClock
2392 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2393
2/4
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109700 times.
109700 if(itemid > -1 && checkbunny(itemid))
2394 109700 tile+=itemsbuf[itemid].ltm;
2395 109700 }
2396
2397
2/2
✓ Branch 0 taken 4672626 times.
✓ Branch 1 taken 1380741 times.
6053367 if(current_item(itype_key))
2398 {
2399 1380741 int32_t itemid =
2400
1/2
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
1380741 get_qr(qr_HARDCODED_LITEM_LTMS)
2401 ? iKey
2402 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2403
2/4
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1380741 times.
1380741 if(itemid > -1 && checkbunny(itemid))
2404 1380741 tile+=itemsbuf[itemid].ltm;
2405 1380741 }
2406
2407
2/2
✓ Branch 0 taken 5786264 times.
✓ Branch 1 taken 267103 times.
6053367 if(current_item(itype_lkey))
2408 {
2409 267103 int32_t itemid =
2410
2/2
✓ Branch 0 taken 266193 times.
✓ Branch 1 taken 910 times.
267103 get_qr(qr_HARDCODED_LITEM_LTMS)
2411 ? iLevelKey
2412 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2413
2/4
✓ Branch 0 taken 267103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 267103 times.
267103 if(itemid > -1 && checkbunny(itemid))
2414 267103 tile+=itemsbuf[itemid].ltm;
2415 267103 }
2416
2417
2/2
✓ Branch 0 taken 1256550 times.
✓ Branch 1 taken 4796817 times.
6053367 if(current_item(itype_map))
2418 {
2419 4796817 int32_t itemid =
2420
2/2
✓ Branch 0 taken 4796031 times.
✓ Branch 1 taken 786 times.
4796817 get_qr(qr_HARDCODED_LITEM_LTMS)
2421 ? iMap
2422 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2423
2/4
✓ Branch 0 taken 4796817 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4796817 times.
4796817 if(itemid > -1 && checkbunny(itemid))
2424 4796817 tile+=itemsbuf[itemid].ltm;
2425 4796817 }
2426
2427
2/2
✓ Branch 0 taken 1234668 times.
✓ Branch 1 taken 4818699 times.
6053367 if(current_item(itype_compass))
2428 {
2429 4818699 int32_t itemid =
2430
2/2
✓ Branch 0 taken 4737640 times.
✓ Branch 1 taken 81059 times.
4818699 get_qr(qr_HARDCODED_LITEM_LTMS)
2431 ? iCompass
2432 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2433
2/4
✓ Branch 0 taken 4818699 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4818699 times.
4818699 if(itemid > -1 && checkbunny(itemid))
2434 4818699 tile+=itemsbuf[itemid].ltm;
2435 4818699 }
2436
2437
2/2
✓ Branch 0 taken 3422822 times.
✓ Branch 1 taken 2630545 times.
6053367 if(current_item(itype_bosskey))
2438 {
2439 2630545 int32_t itemid =
2440
1/2
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
2630545 get_qr(qr_HARDCODED_LITEM_LTMS)
2441 ? iBossKey
2442 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2443
2/4
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2630545 times.
2630545 if(itemid > -1 && checkbunny(itemid))
2444 2630545 tile+=itemsbuf[itemid].ltm;
2445 2630545 }
2446
2447
2/2
✓ Branch 0 taken 2919391 times.
✓ Branch 1 taken 3133976 times.
6053367 if(current_item(itype_magiccontainer))
2448 {
2449 3133976 int32_t itemid =
2450
2/2
✓ Branch 0 taken 3040989 times.
✓ Branch 1 taken 92987 times.
3133976 get_qr(qr_HARDCODED_LITEM_LTMS)
2451 ? iMagicC
2452 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2453
3/4
✓ Branch 0 taken 3133976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 3132106 times.
3133976 if(itemid > -1 && checkbunny(itemid))
2454 3132106 tile+=itemsbuf[itemid].ltm;
2455 3133976 }
2456
2457
2/2
✓ Branch 0 taken 1592733 times.
✓ Branch 1 taken 4460634 times.
6053367 if(current_item(itype_triforcepiece))
2458 {
2459 4460634 int32_t itemid =
2460
1/2
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
4460634 get_qr(qr_HARDCODED_LITEM_LTMS)
2461 ? iTriforce
2462 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2463
2/4
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4460634 times.
4460634 if(itemid > -1 && checkbunny(itemid))
2464 4460634 tile+=itemsbuf[itemid].ltm;
2465 4460634 }
2466
2467
2/2
✓ Branch 0 taken 6053367 times.
✓ Branch 1 taken 3099323904 times.
3105377271 for(int32_t i=0; i<itype_max; i++)
2468 {
2469
2/2
✓ Branch 0 taken 3042451456 times.
✓ Branch 1 taken 56872448 times.
3099323904 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2470 {
2471
2/2
✓ Branch 0 taken 1110790 times.
✓ Branch 1 taken 55761658 times.
56872448 switch(i)
2472 {
2473 case itype_bomb:
2474 case itype_sbomb:
2475 case itype_clock:
2476 case itype_key:
2477 case itype_lkey:
2478 case itype_map:
2479 case itype_compass:
2480 case itype_bosskey:
2481 case itype_magiccontainer:
2482 case itype_triforcepiece:
2483 1110790 continue; //already handled
2484 }
2485 55761658 }
2486 3098213114 int32_t itemid = current_item_id(i,false);
2487
2/2
✓ Branch 0 taken 3092159747 times.
✓ Branch 1 taken 6053367 times.
3098213114 if(i == itype_shield)
2488 6053367 itemid = getCurrentShield(false);
2489
2490
4/4
✓ Branch 0 taken 80855172 times.
✓ Branch 1 taken 3017357942 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 80754191 times.
3098213114 if(itemid < 0 || !checkbunny(itemid))
2491 3017458923 continue;
2492
2493 80754191 itemdata const& itm = itemsbuf[itemid];
2494
2495
2/2
✓ Branch 0 taken 75338158 times.
✓ Branch 1 taken 5416033 times.
80754191 switch(itm.family)
2496 {
2497 case itype_shield:
2498
1/2
✓ Branch 0 taken 5416033 times.
✗ Branch 1 not taken.
5416033 if(itm.flags & ITEM_FLAG9) //active shield
2499 {
2500 if(!usingActiveShield(itemid))
2501 {
2502 tile+=itm.misc6; //'Inactive PTM'
2503 continue;
2504 }
2505 }
2506 5416033 break;
2507 }
2508
2509 80754191 tile+=itm.ltm;
2510 80754191 }
2511
2512 6053367 return tile;
2513 }
2514
2515 6053367 int32_t bunny_tile_mod()
2516 {
2517
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 6051497 times.
6053367 if(Hero.BunnyClock())
2518 {
2519 1870 return game->get_bunny_ltm();
2520 }
2521 6051497 return 0;
2522 6053367 }
2523
2524 // Hints are drawn on a separate layer to combo reveals.
2525 16332 void draw_lens_under(BITMAP *dest, bool layer)
2526 {
2527 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2528 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2529 //Lens flag 3: Don't show armos/chest/dive items
2530 //Lens flag 4: Show Raft Paths
2531 //Lens flag 5: Show Invisible Enemies
2532
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2533
2534 16332 int32_t strike_hint_table[11]=
2535 {
2536 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2537 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2538 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2539 };
2540
2541 // int32_t page = tmpscr->cpage;
2542 {
2543 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2544 // int32_t temptimer=0;
2545 16332 int32_t tempitem, tempweapon=0;
2546 16332 strike_hint=strike_hint_table[strike_hint_counter];
2547
2548
2/2
✓ Branch 0 taken 15842 times.
✓ Branch 1 taken 490 times.
16332 if(strike_hint_timer>32)
2549 {
2550 490 strike_hint_timer=0;
2551 490 strike_hint_counter=((strike_hint_counter+1)%11);
2552 490 }
2553
2554 16332 ++strike_hint_timer;
2555
2556
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2557 {
2558 2874432 int32_t x = (i & 15) << 4;
2559 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2560 2874432 int32_t tempitemx=-16, tempitemy=-16;
2561 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2562
2563
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2564 {
2565 5748864 int32_t checkflag=0;
2566
2567
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2568 {
2569 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2570 2874432 }
2571 else
2572 {
2573 2874432 checkflag=tmpscr->sflag[i];
2574 }
2575
2576
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2577 {
2578
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2579 {
2580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2581 906 }
2582 else
2583 {
2584 192 checkflag = strike_hint;
2585 }
2586 1098 }
2587
2588
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2589 {
2590 case 0:
2591 case mfZELDA:
2592 case mfPUSHED:
2593 case mfENEMY0:
2594 case mfENEMY1:
2595 case mfENEMY2:
2596 case mfENEMY3:
2597 case mfENEMY4:
2598 case mfENEMY5:
2599 case mfENEMY6:
2600 case mfENEMY7:
2601 case mfENEMY8:
2602 case mfENEMY9:
2603 case mfSINGLE:
2604 case mfSINGLE16:
2605 case mfNOENEMY:
2606 case mfTRAP_H:
2607 case mfTRAP_V:
2608 case mfTRAP_4:
2609 case mfTRAP_LR:
2610 case mfTRAP_UD:
2611 case mfNOGROUNDENEMY:
2612 case mfNOBLOCKS:
2613 case mfSCRIPT1:
2614 case mfSCRIPT2:
2615 case mfSCRIPT3:
2616 case mfSCRIPT4:
2617 case mfSCRIPT5:
2618 case mfSCRIPT6:
2619 case mfSCRIPT7:
2620 case mfSCRIPT8:
2621 case mfSCRIPT9:
2622 case mfSCRIPT10:
2623 case mfSCRIPT11:
2624 case mfSCRIPT12:
2625 case mfSCRIPT13:
2626 case mfSCRIPT14:
2627 case mfSCRIPT15:
2628 case mfSCRIPT16:
2629 case mfSCRIPT17:
2630 case mfSCRIPT18:
2631 case mfSCRIPT19:
2632 case mfSCRIPT20:
2633 case mfPITHOLE:
2634 case mfPITFALLFLOOR:
2635 case mfLAVA:
2636 case mfICE:
2637 case mfICEDAMAGE:
2638 case mfDAMAGE1:
2639 case mfDAMAGE2:
2640 case mfDAMAGE4:
2641 case mfDAMAGE8:
2642 case mfDAMAGE16:
2643 case mfDAMAGE32:
2644 case mfFREEZEALL:
2645 case mfFREZEALLANSFFCS:
2646 case mfFREEZEFFCSOLY:
2647 case mfSCRITPTW1TRIG:
2648 case mfSCRITPTW2TRIG:
2649 case mfSCRITPTW3TRIG:
2650 case mfSCRITPTW4TRIG:
2651 case mfSCRITPTW5TRIG:
2652 case mfSCRITPTW6TRIG:
2653 case mfSCRITPTW7TRIG:
2654 case mfSCRITPTW8TRIG:
2655 case mfSCRITPTW9TRIG:
2656 case mfSCRITPTW10TRIG:
2657 case mfTROWEL:
2658 case mfTROWELNEXT:
2659 case mfTROWELSPECIALITEM:
2660 case mfSLASHPOT:
2661 case mfLIFTPOT:
2662 case mfLIFTORSLASH:
2663 case mfLIFTROCK:
2664 case mfLIFTROCKHEAVY:
2665 case mfDROPITEM:
2666 case mfSPECIALITEM:
2667 case mfDROPKEY:
2668 case mfDROPLKEY:
2669 case mfDROPCOMPASS:
2670 case mfDROPMAP:
2671 case mfDROPBOSSKEY:
2672 case mfSPAWNNPC:
2673 case mfSWITCHHOOK:
2674 case mfSIDEVIEWLADDER:
2675 case mfSIDEVIEWPLATFORM:
2676 case mfNOENEMYSPAWN:
2677 case mfENEMYALL:
2678 case mfNOMIRROR:
2679 case mfUNSAFEGROUND:
2680 case mf168:
2681 case mf169:
2682 case mf170:
2683 case mf171:
2684 case mf172:
2685 case mf173:
2686 case mf174:
2687 case mf175:
2688 case mf176:
2689 case mf177:
2690 case mf178:
2691 case mf179:
2692 case mf180:
2693 case mf181:
2694 case mf182:
2695 case mf183:
2696 case mf184:
2697 case mf185:
2698 case mf186:
2699 case mf187:
2700 case mf188:
2701 case mf189:
2702 case mf190:
2703 case mf191:
2704 case mf192:
2705 case mf193:
2706 case mf194:
2707 case mf195:
2708 case mf196:
2709 case mf197:
2710 case mf198:
2711 case mf199:
2712 case mf200:
2713 case mf201:
2714 case mf202:
2715 case mf203:
2716 case mf204:
2717 case mf205:
2718 case mf206:
2719 case mf207:
2720 case mf208:
2721 case mf209:
2722 case mf210:
2723 case mf211:
2724 case mf212:
2725 case mf213:
2726 case mf214:
2727 case mf215:
2728 case mf216:
2729 case mf217:
2730 case mf218:
2731 case mf219:
2732 case mf220:
2733 case mf221:
2734 case mf222:
2735 case mf223:
2736 case mf224:
2737 case mf225:
2738 case mf226:
2739 case mf227:
2740 case mf228:
2741 case mf229:
2742 case mf230:
2743 case mf231:
2744 case mf232:
2745 case mf233:
2746 case mf234:
2747 case mf235:
2748 case mf236:
2749 case mf237:
2750 case mf238:
2751 case mf239:
2752 case mf240:
2753 case mf241:
2754 case mf242:
2755 case mf243:
2756 case mf244:
2757 case mf245:
2758 case mf246:
2759 case mf247:
2760 case mf248:
2761 case mf249:
2762 case mf250:
2763 case mf251:
2764 case mf252:
2765 case mf253:
2766 case mf254:
2767 case mfEXTENDED:
2768 5706470 break;
2769
2770 case mfPUSHUD:
2771 case mfPUSHLR:
2772 case mfPUSH4:
2773 case mfPUSHU:
2774 case mfPUSHD:
2775 case mfPUSHL:
2776 case mfPUSHR:
2777 case mfPUSHUDNS:
2778 case mfPUSHLRNS:
2779 case mfPUSH4NS:
2780 case mfPUSHUNS:
2781 case mfPUSHDNS:
2782 case mfPUSHLNS:
2783 case mfPUSHRNS:
2784 case mfPUSHUDINS:
2785 case mfPUSHLRINS:
2786 case mfPUSH4INS:
2787 case mfPUSHUINS:
2788 case mfPUSHDINS:
2789 case mfPUSHLINS:
2790 case mfPUSHRINS:
2791
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2792
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2793 {
2794 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2795 }
2796
2797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2798
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2799 {
2800
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2801 {
2802
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2803 {
2804 case cPUSH_HEAVY:
2805 case cPUSH_HW:
2806 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2807 72 tempitemx=x, tempitemy=y;
2808
2809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2810 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2811
2812 72 break;
2813
2814 case cPUSH_HEAVY2:
2815 case cPUSH_HW2:
2816 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2817 63 tempitemx=x, tempitemy=y;
2818
2819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2820 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2821
2822 63 break;
2823 }
2824 1032 }
2825 2438 }
2826
2827 3148 break;
2828
2829 case mfWHISTLE:
2830
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2831 {
2832 tempitem=getItemID(itemsbuf,itype_whistle,1);
2833
2834 if(tempitem<0) break;
2835
2836 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2837 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2838 {
2839 tempitemx=x;
2840 tempitemy=y;
2841 }
2842
2843 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2844 }
2845
2846 2418 break;
2847
2848 //Why is this here?
2849 case mfFAIRY:
2850 case mfMAGICFAIRY:
2851 case mfALLFAIRY:
2852 if(hints)
2853 {
2854 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2855
2856 if(tempitem < 0) break;
2857
2858 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2859 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2860 {
2861 tempitemx=x;
2862 tempitemy=y;
2863 }
2864
2865 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2866 }
2867
2868 break;
2869
2870 case mfANYFIRE:
2871
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2872 {
2873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2874 252 }
2875 else
2876 {
2877 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2878
2879
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2880
2881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2882
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2883 {
2884 189 tempitemx=x;
2885 189 tempitemy=y;
2886 189 }
2887
2888 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2889 }
2890
2891 504 break;
2892
2893 case mfSTRONGFIRE:
2894 if(!hints)
2895 {
2896 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2897 }
2898 else
2899 {
2900 tempitem=getItemID(itemsbuf,itype_candle,2);
2901
2902 if(tempitem<0) break;
2903
2904 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2905 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2906 {
2907 tempitemx=x;
2908 tempitemy=y;
2909 }
2910
2911 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2912 }
2913
2914 break;
2915
2916 case mfMAGICFIRE:
2917 if(!hints)
2918 {
2919 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2920 }
2921 else
2922 {
2923 tempitem=getItemID(itemsbuf,itype_wand,1);
2924
2925 if(tempitem<0) break;
2926
2927 tempweapon=wFire;
2928
2929 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2930 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2931 {
2932 tempitemx=x;
2933 tempitemy=y;
2934 }
2935 else
2936 {
2937 tempweaponx=x;
2938 tempweapony=y;
2939 }
2940
2941 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2942 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2943 }
2944
2945 break;
2946
2947 case mfDIVINEFIRE:
2948 if(!hints)
2949 {
2950 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2951 }
2952 else
2953 {
2954 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2955
2956 if(tempitem<0) break;
2957
2958 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2959 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2960 {
2961 tempitemx=x;
2962 tempitemy=y;
2963 }
2964
2965 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2966 }
2967
2968 break;
2969
2970 case mfARROW:
2971
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2972 {
2973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2974 732 }
2975 else
2976 {
2977 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2978
2979
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2980
2981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2982
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2983 {
2984 61 tempitemx=x;
2985 61 tempitemy=y;
2986 61 }
2987
2988 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2989 }
2990
2991 814 break;
2992
2993 case mfSARROW:
2994 if(!hints)
2995 {
2996 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2997 }
2998 else
2999 {
3000 tempitem=getItemID(itemsbuf,itype_arrow,2);
3001
3002 if(tempitem<0) break;
3003
3004 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3005 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3006 {
3007 tempitemx=x;
3008 tempitemy=y;
3009 }
3010
3011 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3012 }
3013
3014 break;
3015
3016 case mfGARROW:
3017 if(!hints)
3018 {
3019 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3020 }
3021 else
3022 {
3023 tempitem=getItemID(itemsbuf,itype_arrow,3);
3024
3025 if(tempitem<0) break;
3026
3027 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3028 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3029 {
3030 tempitemx=x;
3031 tempitemy=y;
3032 }
3033
3034 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3035 }
3036
3037 break;
3038
3039 case mfBOMB:
3040
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3041 {
3042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3043 16 }
3044 else
3045 {
3046 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3047 17 tempweapon = wLitBomb;
3048
3049 //if (tempitem<0) break;
3050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3051
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3052 {
3053 12 tempweaponx=x;
3054 12 tempweapony=y;
3055 12 }
3056
3057 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3058 }
3059
3060 33 break;
3061
3062 case mfSBOMB:
3063
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3064 {
3065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3066 48 }
3067 else
3068 {
3069 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3070 //if (tempitem<0) break;
3071 48 tempweapon = wLitSBomb;
3072
3073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3074
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3075 {
3076 36 tempweaponx=x;
3077 36 tempweapony=y;
3078 36 }
3079
3080 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3081 }
3082
3083 96 break;
3084
3085 case mfARMOS_SECRET:
3086
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3087 {
3088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3089 12 }
3090 24 break;
3091
3092 case mfBRANG:
3093
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3094 {
3095 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3096 }
3097 else
3098 {
3099 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3100
3101
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3102
3103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3104
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3105 {
3106 4 tempitemx=x;
3107 4 tempitemy=y;
3108 4 }
3109
3110 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3111 }
3112
3113 5 break;
3114
3115 case mfMBRANG:
3116 if(!hints)
3117 {
3118 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3119 }
3120 else
3121 {
3122 tempitem=getItemID(itemsbuf,itype_brang,2);
3123
3124 if(tempitem<0) break;
3125
3126 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3127 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3128 {
3129 tempitemx=x;
3130 tempitemy=y;
3131 }
3132
3133 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3134 }
3135
3136 break;
3137
3138 case mfFBRANG:
3139 if(!hints)
3140 {
3141 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3142 }
3143 else
3144 {
3145 tempitem=getItemID(itemsbuf,itype_brang,3);
3146
3147 if(tempitem<0) break;
3148
3149 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3150 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3151 {
3152 tempitemx=x;
3153 tempitemy=y;
3154 }
3155
3156 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3157 }
3158
3159 break;
3160
3161 case mfWANDMAGIC:
3162 if(!hints)
3163 {
3164 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3165 }
3166 else
3167 {
3168 tempitem=getItemID(itemsbuf,itype_wand,1);
3169
3170 if(tempitem<0) break;
3171
3172 tempweapon=itemsbuf[tempitem].wpn3;
3173
3174 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3175 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3176 {
3177 tempitemx=x;
3178 tempitemy=y;
3179 }
3180 else
3181 {
3182 tempweaponx=x;
3183 tempweapony=y;
3184 --lens_hint_weapon[wMagic][4];
3185
3186 if(lens_hint_weapon[wMagic][4]<-8)
3187 {
3188 lens_hint_weapon[wMagic][4]=8;
3189 }
3190 }
3191
3192 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3193 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3194 }
3195
3196 break;
3197
3198 case mfREFMAGIC:
3199
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3200 {
3201 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3202 }
3203 else
3204 {
3205 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3206
3207
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3208
3209 16 tempweapon=ewMagic;
3210
3211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3212
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3213 {
3214 13 tempitemx=x;
3215 13 tempitemy=y;
3216 13 }
3217 else
3218 {
3219 3 tempweaponx=x;
3220 3 tempweapony=y;
3221
3222
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3223 {
3224 1 --lens_hint_weapon[ewMagic][4];
3225 1 }
3226 else
3227 {
3228 2 ++lens_hint_weapon[ewMagic][4];
3229 }
3230
3231
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3232 {
3233 lens_hint_weapon[ewMagic][2]=up;
3234 }
3235
3236
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3237 {
3238 2 lens_hint_weapon[ewMagic][2]=down;
3239 2 }
3240 }
3241
3242 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3243 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3244 }
3245
3246 16 break;
3247
3248 case mfREFFIREBALL:
3249
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3250 {
3251 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3252 }
3253 else
3254 {
3255 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3256
3257
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3258
3259 16 tempweapon=ewFireball;
3260
3261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3262
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3263 {
3264 12 tempitemx=x;
3265 12 tempitemy=y;
3266 12 tempweaponx=x;
3267 12 tempweapony=y;
3268 12 ++lens_hint_weapon[ewFireball][3];
3269
3270
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3271 {
3272 1 lens_hint_weapon[ewFireball][3]=-8;
3273 1 lens_hint_weapon[ewFireball][4]=8;
3274 1 }
3275
3276
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3277 {
3278 8 ++lens_hint_weapon[ewFireball][4];
3279 8 }
3280 else
3281 {
3282 4 --lens_hint_weapon[ewFireball][4];
3283 }
3284 12 }
3285
3286 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3287 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3288 }
3289
3290 16 break;
3291
3292 case mfSWORD:
3293
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3294 {
3295 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3296 }
3297 else
3298 {
3299 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3300
3301
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3302
3303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3304
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3305 {
3306 5 tempitemx=x;
3307 5 tempitemy=y;
3308 5 }
3309
3310 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3311 }
3312
3313 7 break;
3314
3315 case mfWSWORD:
3316 if(!hints)
3317 {
3318 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3319 }
3320 else
3321 {
3322 tempitem=getItemID(itemsbuf,itype_sword,2);
3323
3324 if(tempitem<0) break;
3325
3326 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3327 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3328 {
3329 tempitemx=x;
3330 tempitemy=y;
3331 }
3332
3333 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3334 }
3335
3336 break;
3337
3338 case mfMSWORD:
3339 if(!hints)
3340 {
3341 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3342 }
3343 else
3344 {
3345 tempitem=getItemID(itemsbuf,itype_sword,3);
3346
3347 if(tempitem<0) break;
3348
3349 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3350 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3351 {
3352 tempitemx=x;
3353 tempitemy=y;
3354 }
3355
3356 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3357 }
3358
3359 break;
3360
3361 case mfXSWORD:
3362 if(!hints)
3363 {
3364 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3365 }
3366 else
3367 {
3368 tempitem=getItemID(itemsbuf,itype_sword,4);
3369
3370 if(tempitem<0) break;
3371
3372 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3373 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3374 {
3375 tempitemx=x;
3376 tempitemy=y;
3377 }
3378
3379 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3380 }
3381
3382 break;
3383
3384 case mfSWORDBEAM:
3385
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3386 {
3387 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3388 }
3389 else
3390 {
3391 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3392
3393
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3394
3395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3396
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3397 {
3398 11 tempitemx=x;
3399 11 tempitemy=y;
3400 11 }
3401
3402 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3403 }
3404
3405 16 break;
3406
3407 case mfWSWORDBEAM:
3408 if(!hints)
3409 {
3410 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3411 }
3412 else
3413 {
3414 tempitem=getItemID(itemsbuf,itype_sword,2);
3415
3416 if(tempitem<0) break;
3417
3418 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3419 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3420 {
3421 tempitemx=x;
3422 tempitemy=y;
3423 }
3424
3425 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3426 }
3427
3428 break;
3429
3430 case mfMSWORDBEAM:
3431 if(!hints)
3432 {
3433 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3434 }
3435 else
3436 {
3437 tempitem=getItemID(itemsbuf,itype_sword,3);
3438
3439 if(tempitem<0) break;
3440
3441 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3442 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3443 {
3444 tempitemx=x;
3445 tempitemy=y;
3446 }
3447
3448 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3449 }
3450
3451 break;
3452
3453 case mfXSWORDBEAM:
3454 if(!hints)
3455 {
3456 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3457 }
3458 else
3459 {
3460 tempitem=getItemID(itemsbuf,itype_sword,4);
3461
3462 if(tempitem<0) break;
3463
3464 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3465 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3466 {
3467 tempitemx=x;
3468 tempitemy=y;
3469 }
3470
3471 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3472 }
3473
3474 break;
3475
3476 case mfHOOKSHOT:
3477
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3478 {
3479 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3480 }
3481 else
3482 {
3483 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3484
3485
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3486
3487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3488
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3489 {
3490 12 tempitemx=x;
3491 12 tempitemy=y;
3492 12 }
3493
3494 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3495 }
3496
3497 17 break;
3498
3499 case mfWAND:
3500
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3501 {
3502 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3503 }
3504 else
3505 {
3506 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3507
3508
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3509
3510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3511
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3512 {
3513 28 tempitemx=x;
3514 28 tempitemy=y;
3515 28 }
3516
3517 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3518 }
3519
3520 35 break;
3521
3522 case mfHAMMER:
3523
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3524 {
3525 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3526 }
3527 else
3528 {
3529 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3530
3531
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3532
3533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3534
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3535 {
3536 13 tempitemx=x;
3537 13 tempitemy=y;
3538 13 }
3539
3540 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3541 }
3542
3543 17 break;
3544
3545 case mfARMOS_ITEM:
3546 case mfDIVE_ITEM:
3547
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3548 {
3549 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3550 2064 }
3551 2064 break;
3552
3553 case 16:
3554 case 17:
3555 case 18:
3556 case 19:
3557 case 20:
3558 case 21:
3559 case 22:
3560 case 23:
3561 case 24:
3562 case 25:
3563 case 26:
3564 case 27:
3565 case 28:
3566 case 29:
3567 case 30:
3568 case 31:
3569
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3571 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3572
3573 3618 break;
3574 case mfSECRETSNEXT:
3575 if(!hints)
3576 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3577 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3578
3579 break;
3580
3581 case mfSTRIKE:
3582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3583 {
3584 906 goto special;
3585 }
3586 else
3587 {
3588 break;
3589 }
3590
3591 28640 default: goto special;
3592
3593 special:
3594
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3595 {
3596
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3597 {
3598 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3599 4913 }
3600 6549 }
3601
3602 29546 break;
3603 }
3604 5748864 }
3605 2874432 }
3606
3607
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3608 {
3609
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3610 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3611
3612
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3613 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3614
3615
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3616 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3617
3618
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3619 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3620
3621
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3622 {
3623 43 showbombeddoor(dest, 0);
3624 43 }
3625
3626
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3627 {
3628 39 showbombeddoor(dest, 1);
3629 39 }
3630
3631
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3632 {
3633 showbombeddoor(dest, 2);
3634 }
3635
3636
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3637 {
3638 37 showbombeddoor(dest, 3);
3639 37 }
3640 8166 }
3641
3642
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3643 {
3644
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3645 {
3646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3647 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3648 1123 }
3649 else
3650 {
3651
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3652 {
3653 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3654 48 int32_t tempitemx=-16;
3655 48 int32_t tempitemy=-16;
3656
3657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3658
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3659 {
3660 24 tempitemx=tmpscr->stairx;
3661 24 tempitemy=tmpscr->stairy+playing_field_offset;
3662 24 }
3663
3664 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3665 48 }
3666 }
3667 2034 }
3668 }
3669 16332 }
3670
3671 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3672
3673 7997 void draw_lens_over()
3674 {
3675 // Oh, what the heck.
3676 static BITMAP *lens_scr = NULL;
3677 static int32_t last_width = -1;
3678 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3679
3680 // Only redraw the circle if the size has changed
3681
2/2
✓ Branch 0 taken 7987 times.
✓ Branch 1 taken 10 times.
7997 if(width != last_width)
3682 {
3683
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(lens_scr == NULL)
3684 {
3685 10 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3686 10 }
3687
3688 10 clear_to_color(lens_scr, BLACK);
3689 10 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3690 10 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3691 10 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3692 10 last_width=width;
3693 10 }
3694
3695 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3696 7997 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3697 7997 }
3698
3699 //----------------------------------------------------------------
3700
3701 31111 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3702 {
3703 //recreating a big bitmap every frame is highly sluggish.
3704
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 31108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
31111 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3705 31111 clear_to_color(wavebuf, BLACK);
3706 31111 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3707
3708 int32_t ofs;
3709 // int32_t amplitude=8;
3710 // int32_t wavelength=4;
3711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31111 times.
31111 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3712
3/6
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3713 31111 int32_t amp2=168;
3714
2/4
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3715 31111 int32_t i=frame%amp2;
3716
3717
2/2
✓ Branch 0 taken 5226648 times.
✓ Branch 1 taken 31111 times.
5257759 for(int32_t j=0; j<168; j++)
3718 {
3719
3/4
✓ Branch 0 taken 2613324 times.
✓ Branch 1 taken 2613324 times.
✓ Branch 2 taken 2613324 times.
✗ Branch 3 not taken.
5226648 if(j&1 && interpol)
3720 {
3721 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3722 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3723 }
3724 else
3725 {
3726 5226648 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3727 }
3728
3729
1/2
✓ Branch 0 taken 5226648 times.
✗ Branch 1 not taken.
5226648 if(ofs)
3730 {
3731
2/2
✓ Branch 0 taken 1338021888 times.
✓ Branch 1 taken 5226648 times.
1343248536 for(int32_t k=0; k<256; k++)
3732 {
3733 1338021888 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3734 1338021888 }
3735 5226648 }
3736 5226648 }
3737 31111 }
3738
3739 4848 void draw_fuzzy(int32_t fuzz)
3740 // draws from right half of scrollbuf to framebuf
3741 {
3742 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3743 byte *start, *si, *di;
3744
3745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4848 times.
4848 if(fuzz<1)
3746 fuzz = 1;
3747
3748 4848 xstep = 128%fuzz;
3749
3750
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 3838 times.
4848 if(xstep > 0)
3751 3838 xstep = fuzz-xstep;
3752
3753 4848 ystep = 112%fuzz;
3754
3755
2/2
✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 3434 times.
4848 if(ystep > 0)
3756 3434 ystep = fuzz-ystep;
3757
3758 4848 firsty = 1;
3759
3760
2/2
✓ Branch 0 taken 4848 times.
✓ Branch 1 taken 174932 times.
179780 for(y=0; y<224;)
3761 {
3762 174932 start = &(scrollbuf->line[y][256]);
3763
3764
4/4
✓ Branch 0 taken 172508 times.
✓ Branch 1 taken 1088376 times.
✓ Branch 2 taken 1085952 times.
✓ Branch 3 taken 174932 times.
1260884 for(dy=0; dy<ystep && dy+y<224; dy++)
3765 {
3766 1085952 si = start;
3767 1085952 di = &(framebuf->line[y+dy][0]);
3768 1085952 i = xstep;
3769 1085952 firstx = 1;
3770
3771
2/2
✓ Branch 0 taken 278003712 times.
✓ Branch 1 taken 1085952 times.
279089664 for(dx=0; dx<256; dx++)
3772 {
3773 278003712 *(di++) = *si;
3774
3775
2/2
✓ Branch 0 taken 234248896 times.
✓ Branch 1 taken 43754816 times.
278003712 if(++i >= fuzz)
3776 {
3777
2/2
✓ Branch 0 taken 42668864 times.
✓ Branch 1 taken 1085952 times.
43754816 if(!firstx)
3778 42668864 si += fuzz;
3779 else
3780 {
3781 1085952 si += fuzz-xstep;
3782 1085952 firstx = 0;
3783 }
3784
3785 43754816 i = 0;
3786 43754816 }
3787 278003712 }
3788 1085952 }
3789
3790
2/2
✓ Branch 0 taken 170084 times.
✓ Branch 1 taken 4848 times.
174932 if(!firsty)
3791 170084 y += fuzz;
3792 else
3793 {
3794 4848 y += ystep;
3795 4848 ystep = fuzz;
3796 4848 firsty = 0;
3797 }
3798 }
3799 4848 }
3800
3801 9286804 void updatescr(bool allowwavy)
3802 {
3803
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9286688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
9286804 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3804
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9286688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
9286804 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3805
3806
2/2
✓ Branch 0 taken 9260039 times.
✓ Branch 1 taken 26765 times.
9286804 if(toogam)
3807 {
3808 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3809 26765 }
3810
3811
1/2
✓ Branch 0 taken 9286804 times.
✗ Branch 1 not taken.
9286804 if(Showpal)
3812 dump_pal(framebuf);
3813
3814
2/2
✓ Branch 0 taken 8985572 times.
✓ Branch 1 taken 301232 times.
9286804 if(!Playing)
3815 301232 black_opening_count=0;
3816
3817
2/2
✓ Branch 0 taken 9213478 times.
✓ Branch 1 taken 73326 times.
9286804 if(black_opening_count<0) //shape is opening up
3818 {
3819 73326 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3820
3821
2/4
✓ Branch 0 taken 73326 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73326 times.
73326 if(Advance||(!Paused))
3822 {
3823 73326 ++black_opening_count;
3824 73326 }
3825 73326 }
3826
2/2
✓ Branch 0 taken 9187342 times.
✓ Branch 1 taken 26136 times.
9213478 else if(black_opening_count>0) //shape is closing
3827 {
3828 26136 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3829
3830
2/4
✓ Branch 0 taken 26136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26136 times.
26136 if(Advance||(!Paused))
3831 {
3832 26136 --black_opening_count;
3833 26136 }
3834 26136 }
3835
3836
3/4
✓ Branch 0 taken 9188849 times.
✓ Branch 1 taken 97955 times.
✓ Branch 2 taken 9188849 times.
✗ Branch 3 not taken.
9286804 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3837 {
3838 black_opening_shape = bosCIRCLE;
3839 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3840 refreshTints();
3841 refreshpal=true;
3842 }
3843
3844
2/2
✓ Branch 0 taken 9032603 times.
✓ Branch 1 taken 254201 times.
9286804 if(refreshpal)
3845 {
3846 254201 refreshpal=false;
3847 254201 RAMpal[253] = _RGB(0,0,0);
3848 254201 RAMpal[254] = _RGB(63,63,63);
3849 254201 hw_palette = &RAMpal;
3850 254201 update_hw_pal = true;
3851
3852 254201 create_rgb_table(&rgb_table, RAMpal, NULL);
3853 254201 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3854 254201 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3855
3856
2/2
✓ Branch 0 taken 65075456 times.
✓ Branch 1 taken 254201 times.
65329657 for(int32_t q=0; q<PAL_SIZE; q++)
3857 {
3858 65075456 trans_table2.data[0][q] = q;
3859 65075456 trans_table2.data[q][q] = q;
3860 65075456 }
3861 254201 }
3862
3863 9286804 bool clearwavy = (wavy <= 0);
3864
3865
2/2
✓ Branch 0 taken 7655 times.
✓ Branch 1 taken 9279149 times.
9286804 if(wavy <= 0)
3866 {
3867 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3868 9279149 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3869 9279149 }
3870
3871 9286804 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3872
3873
6/6
✓ Branch 0 taken 31361 times.
✓ Branch 1 taken 9255443 times.
✓ Branch 2 taken 31239 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31111 times.
9286804 if(wavy && Playing && allowwavy)
3874 {
3875 31111 draw_wavy(framebuf, wavybuf, wavy,false);
3876 31111 }
3877
3878
2/2
✓ Branch 0 taken 9279149 times.
✓ Branch 1 taken 7655 times.
9286804 if(clearwavy)
3879 9279149 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3880
2/4
✓ Branch 0 taken 7655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7655 times.
7655 else if(Playing && !Paused)
3881 7655 wavy--; // Wavy was set by a script. Decrement it.
3882
3883
5/6
✓ Branch 0 taken 8985572 times.
✓ Branch 1 taken 301232 times.
✓ Branch 2 taken 259574 times.
✓ Branch 3 taken 8725998 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 259574 times.
9286804 if(Playing && msgpos && !screenscrolling)
3884 {
3885
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_bg_display_buf->clip))
3886 259574 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3887
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_portrait_display_buf->clip))
3888 259574 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3889
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_txt_display_buf->clip))
3890 259574 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3891 259574 }
3892
3893 /*
3894 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3895 {
3896 BITMAP* subBmp = 0;
3897 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3898 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3899 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3900 destroy_bitmap(subBmp);
3901 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3902 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3903 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3904 }
3905 */
3906
3907
2/2
✓ Branch 0 taken 9245747 times.
✓ Branch 1 taken 41057 times.
9286804 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3908
3909
2/2
✓ Branch 0 taken 9250372 times.
✓ Branch 1 taken 36432 times.
9286804 if(nosubscr)
3910 {
3911 36432 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3912 36432 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3913 36432 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3914 36432 }
3915
3916 //TODO: Optimize blit 'overcalls' -Gleeok
3917
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9250372 times.
9286804 BITMAP *source = nosubscr ? panorama : wavybuf;
3918 9286804 blit(source,framebuf,0,0,0,0,256,224);
3919
3920 9286804 update_hw_screen();
3921 9286804 }
3922
3923 //----------------------------------------------------------------
3924
3925 static PALETTE syspal;
3926 int32_t onGUISnapshot()
3927 {
3928 char buf[200];
3929 int32_t num=0;
3930 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3931 do
3932 {
3933 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3934 }
3935 while(num<99999 && exists(buf));
3936
3937 BITMAP *b = create_bitmap_ex(8,resx,resy);
3938
3939 if(b)
3940 {
3941 blit(screen,b,0,0,0,0,resx,resy);
3942 save_bitmap(buf,screen,RAMpal);
3943 destroy_bitmap(b);
3944 }
3945
3946 return D_O_K;
3947 }
3948
3949 int32_t onNonGUISnapshot()
3950 {
3951 PALETTE temppal;
3952 get_palette(temppal);
3953 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3954
3955 char buf[200];
3956 int32_t num=0;
3957
3958 do
3959 {
3960 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3961 }
3962 while(num<99999 && exists(buf));
3963
3964 if (tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3965 {
3966 BITMAP *b = create_bitmap_ex(8,256,168);
3967 clear_to_color(b,0);
3968 blit(framebuf,b,0,passive_subscreen_height/2,0,0,256,168);
3969 save_bitmap(buf,b,realpal?temppal:RAMpal);
3970 destroy_bitmap(b);
3971 }
3972 else
3973 {
3974 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3975 }
3976
3977 return D_O_K;
3978 }
3979
3980 int32_t onSnapshot()
3981 {
3982 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3983 {
3984 onGUISnapshot();
3985 }
3986 else
3987 {
3988 onNonGUISnapshot();
3989 }
3990
3991 return D_O_K;
3992 }
3993
3994 int32_t onSaveMapPic()
3995 {
3996 int32_t mapres2 = 0;
3997 char buf[200];
3998 int32_t num=0;
3999 mapscr tmpscr_b[2];
4000 mapscr tmpscr_c[6];
4001 BITMAP* _screen_draw_buffer = NULL;
4002 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4003 set_clip_state(_screen_draw_buffer,1);
4004
4005 for(int32_t i=0; i<6; ++i)
4006 {
4007 tmpscr_c[i] = tmpscr2[i];
4008 tmpscr2[i].zero_memory();
4009
4010 if(i>=2)
4011 {
4012 continue;
4013 }
4014
4015 tmpscr_b[i] = tmpscr[i];
4016 tmpscr[i].zero_memory();
4017 }
4018
4019 do
4020 {
4021 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4022 }
4023 while(num<99999 && exists(buf));
4024
4025 BITMAP* mappic = NULL;
4026
4027
4028 bool done=false, redraw=true;
4029
4030 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4031
4032 if(!mappic)
4033 {
4034 enter_sys_pal();
4035 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4036 exit_sys_pal();
4037 return D_O_K;;
4038 }
4039
4040 // draw the map
4041 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4042
4043 for(int32_t y=0; y<8; y++)
4044 {
4045 for(int32_t x=0; x<16; x++)
4046 {
4047 if(!displayOnMap(x, y))
4048 {
4049 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4050 }
4051 else
4052 {
4053 int32_t s = (y<<4) + x;
4054 loadscr2(1,s,-1);
4055
4056 for(int32_t i=0; i<6; i++)
4057 {
4058 if(tmpscr[1].layermap[i]<=0)
4059 continue;
4060
4061 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4062 }
4063
4064 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4065
4066 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4067
4068 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4069 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4070
4071 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4072
4073 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4074 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4075 {
4076 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4077 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4078 {
4079 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4080 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4081 }
4082 }
4083 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4084
4085 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4086
4087 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4088 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4089 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4090 {
4091 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4092 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4093 }
4094 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4095 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4096
4097 }
4098
4099 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4100 }
4101 }
4102
4103 for(int32_t i=0; i<6; ++i)
4104 {
4105 tmpscr2[i]=tmpscr_c[i];
4106
4107 if(i>=2)
4108 {
4109 continue;
4110 }
4111
4112 tmpscr[i]=tmpscr_b[i];
4113 }
4114
4115 save_bitmap(buf,mappic,RAMpal);
4116 destroy_bitmap(mappic);
4117 destroy_bitmap(_screen_draw_buffer);
4118 return D_O_K;
4119 }
4120
4121 14 void f_Quit(int32_t type)
4122 {
4123
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4124 return;
4125
4126 14 bool from_menu = is_sys_pal;
4127
4128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4129 {
4130 14 music_pause();
4131 14 pause_all_sfx();
4132 14 sys_mouse();
4133 14 }
4134 14 enter_sys_pal();
4135 14 clear_keybuf();
4136
4137
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (replay_version_check(0, 10))
4138 13 replay_poll();
4139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4140 14 replay_peek_quit();
4141
4142
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4143 switch(type)
4144 {
4145 case qQUIT:
4146 onQuit();
4147 break;
4148
4149 case qRESET:
4150 onReset();
4151 break;
4152
4153 case qEXIT:
4154 onExit();
4155 break;
4156 }
4157
4158
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4159 {
4160 14 kill_sfx();
4161 14 music_stop();
4162 14 exit_sys_pal();
4163 14 update_hw_screen();
4164 14 }
4165 else
4166 {
4167 exit_sys_pal();
4168 if(!from_menu)
4169 {
4170 music_resume();
4171 resume_all_sfx();
4172 }
4173 }
4174
4175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4176 14 game_mouse();
4177 14 eat_buttons();
4178
4179 14 zc_readrawkey(KEY_ESC);
4180
4181 14 zc_readrawkey(KEY_ENTER);
4182 14 }
4183
4184 //----------------------------------------------------------------
4185
4186 int32_t onNoWalls()
4187 {
4188 cheats_enqueue(Cheat::Walls);
4189 return D_O_K;
4190 }
4191
4192 int32_t onIgnoreSideview()
4193 {
4194 cheats_enqueue(Cheat::IgnoreSideView);
4195 return D_O_K;
4196 }
4197
4198 9286678 int32_t input_idle(bool checkmouse)
4199 {
4200 static int32_t mx, my, mz, mb;
4201
4202
4/6
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461637 times.
✓ Branch 3 taken 6825041 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2461637 times.
11748315 if(keypressed() || zc_key_pressed() ||
4203
4/8
✓ Branch 0 taken 2461637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461637 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2461637 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2461637 times.
✗ Branch 7 not taken.
2461637 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4204 {
4205 6825041 idle_count = 0;
4206
4207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6825041 times.
6825041 if(active_count < MAX_ACTIVE)
4208 {
4209 6825041 ++active_count;
4210 6825041 }
4211 6825041 }
4212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2461637 times.
2461637 else if(idle_count < MAX_IDLE)
4213 {
4214 2461637 ++idle_count;
4215 2461637 active_count = 0;
4216 2461637 }
4217
4218 9286678 mx = mouse_x;
4219 9286678 my = mouse_y;
4220 9286678 mz = mouse_z;
4221 9286678 mb = mouse_b;
4222
4223 9286678 return idle_count;
4224 }
4225
4226 int32_t onGoFast()
4227 {
4228 cheats_enqueue(Cheat::Fast);
4229 return D_O_K;
4230 }
4231
4232 int32_t onKillCheat()
4233 {
4234 cheats_enqueue(Cheat::Kill);
4235 return D_O_K;
4236 }
4237
4238 int32_t onSecretsCheat()
4239 {
4240 cheats_enqueue(Cheat::TrigSecrets);
4241 return D_O_K;
4242 }
4243 int32_t onSecretsCheatPerm()
4244 {
4245 cheats_enqueue(Cheat::TrigSecretsPerm);
4246 return D_O_K;
4247 }
4248
4249 int32_t onShowLayer0()
4250 {
4251 show_layer_0 = !show_layer_0;
4252 return D_O_K;
4253 }
4254 int32_t onShowLayer1()
4255 {
4256 show_layer_1 = !show_layer_1;
4257 return D_O_K;
4258 }
4259 int32_t onShowLayer2()
4260 {
4261 show_layer_2 = !show_layer_2;
4262 return D_O_K;
4263 }
4264 int32_t onShowLayer3()
4265 {
4266 show_layer_3 = !show_layer_3;
4267 return D_O_K;
4268 }
4269 int32_t onShowLayer4()
4270 {
4271 show_layer_4 = !show_layer_4;
4272 return D_O_K;
4273 }
4274 int32_t onShowLayer5()
4275 {
4276 show_layer_5 = !show_layer_5;
4277 return D_O_K;
4278 }
4279 int32_t onShowLayer6()
4280 {
4281 show_layer_6 = !show_layer_6;
4282 return D_O_K;
4283 }
4284 int32_t onShowLayerO()
4285 {
4286 show_layer_over=!show_layer_over;
4287 return D_O_K;
4288 }
4289 int32_t onShowLayerP()
4290 {
4291 show_layer_push=!show_layer_push;
4292 return D_O_K;
4293 }
4294 int32_t onShowLayerS()
4295 {
4296 show_sprites=!show_sprites;
4297 return D_O_K;
4298 }
4299 int32_t onShowLayerF()
4300 {
4301 show_ffcs=!show_ffcs;
4302 return D_O_K;
4303 }
4304 int32_t onShowLayerW()
4305 {
4306 show_walkflags=!show_walkflags;
4307 if(show_walkflags)
4308 show_effectflags = false;
4309 return D_O_K;
4310 }
4311 int32_t onShowLayerE()
4312 {
4313 show_effectflags=!show_effectflags;
4314 if(show_effectflags)
4315 show_walkflags = false;
4316 return D_O_K;
4317 }
4318 int32_t onShowFFScripts()
4319 {
4320 show_ff_scripts=!show_ff_scripts;
4321 return D_O_K;
4322 }
4323 int32_t onShowHitboxes()
4324 {
4325 show_hitboxes=!show_hitboxes;
4326 return D_O_K;
4327 }
4328 int32_t onShowInfoOpacity()
4329 {
4330 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4331 zc_set_config("zc","debug_info_opacity",info_opacity);
4332 return D_O_K;
4333 }
4334
4335 int32_t onLightSwitch()
4336 {
4337 cheats_enqueue(Cheat::Light);
4338 return D_O_K;
4339 }
4340
4341 int32_t onGoTo();
4342 int32_t onGoToComplete();
4343
4344 9286678 bool handle_close_btn_quit()
4345 {
4346
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(close_button_quit)
4347 {
4348 close_button_quit=false;
4349 f_Quit(qEXIT);
4350 }
4351 9286678 return (exiting_program = Quit==qEXIT);
4352 }
4353
4354 9286678 void syskeys()
4355 {
4356 9286678 update_system_keys();
4357
4358 int32_t oldtitle_version;
4359
4360 9286678 poll_joystick();
4361
4362 9286678 handle_close_btn_quit();
4363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
9286678 if(Quit == qEXIT) return;
4364
4365
2/10
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9286678 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9286678 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4366 {
4367 System();
4368 }
4369
4370 9286678 mouse_down=gui_mouse_b();
4371
4372
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(zc_read_system_key(KEY_F1))
4373 {
4374 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4375 {
4376 halt=!halt;
4377 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4378 }
4379 else
4380 {
4381 Throttlefps=!Throttlefps;
4382 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4383 }
4384 }
4385
4386 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4387 /*
4388 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4389 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4390 */
4391
4392
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(zc_read_system_key(KEY_F2))
4393 {
4394 ShowFPS=!ShowFPS;
4395 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4396 }
4397
4398
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9286678 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4399
4400
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9286678 if(zc_read_system_key(KEY_F4) && Playing)
4401 {
4402 Paused=true;
4403 Advance=true;
4404 }
4405
4406
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(zc_read_system_key(KEY_F6)) onTryQuit();
4407
4408 #ifndef ALLEGRO_MACOSX
4409
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4410
4411
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4412 #else
4413 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4414
4415 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4416 #endif
4417
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9286678 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4418
4419
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if (zc_read_system_key(KEY_F12))
4420 {
4421 onSnapshot();
4422 }
4423
4424
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9286678 if(debug_enabled && zc_read_system_key(KEY_TAB))
4425 set_debug(!get_debug());
4426
4427
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(CheatModifierKeys())
4428 {
4429 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4430 {
4431 if(!bindable_cheat(c))
4432 continue;
4433 if(get_debug() || cheat >= cheat_lvl(c))
4434 {
4435 if(checkcheat(c))
4436 cheats_hit_bind(c);
4437 }
4438 }
4439 }
4440
4441
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(volkeys)
4442 {
4443 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4444
4445 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4446
4447 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4448
4449 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4450 }
4451
4452
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9286678 if(!get_debug() || !SystemKeys || replay_is_replaying())
4453 9286678 goto bottom;
4454
4455 if(zc_readkey(KEY_D))
4456 {
4457 details = !details;
4458 rectfill(screen,0,0,319,7,BLACK);
4459 rectfill(screen,0,8,31,239,BLACK);
4460 rectfill(screen,288,8,319,239,BLACK);
4461 rectfill(screen,32,232,287,239,BLACK);
4462 }
4463
4464 if(zc_readkey(KEY_P)) Paused=!Paused;
4465
4466 //if(zc_readkey(KEY_P)) centerHero();
4467 if(zc_readkey(KEY_A))
4468 {
4469 Paused=true;
4470 Advance=true;
4471 }
4472
4473 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4474 #ifndef ALLEGRO_MACOSX
4475 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4476
4477 if(zc_readkey(KEY_F7))
4478 {
4479 Matrix(ss_speed, ss_density, 0);
4480 game_pal();
4481 }
4482 #else
4483 // The reason these are different on Mac in the first place is that
4484 // the OS doesn't let us use F9 and F10...
4485 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4486
4487 if(zc_readkey(KEY_F9))
4488 {
4489 Matrix(ss_speed, ss_density, 0);
4490 game_pal();
4491 }
4492 #endif
4493 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4494 {
4495 //change containers
4496 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4497 {
4498 //magic containers
4499 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4500 {
4501 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4502 }
4503 else
4504 {
4505 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4506 }
4507 }
4508 else
4509 {
4510 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4511 {
4512 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4513 }
4514 else
4515 {
4516 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4517 }
4518 }
4519 }
4520
4521 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4522 {
4523 //change containers
4524 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4525 {
4526 //magic containers
4527 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4528 {
4529 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4530 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4531 //heart containers
4532 }
4533 else
4534 {
4535 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4536 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4537 }
4538 }
4539 else
4540 {
4541 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4542 {
4543 game->set_magic(zc_max(game->get_magic()-1,0));
4544 }
4545 else
4546 {
4547 game->set_life(zc_max(game->get_life()-1,0));
4548 }
4549 }
4550 }
4551
4552 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4553
4554 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4555
4556 verifyBothWeapons();
4557
4558 bottom:
4559
4560
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(input_idle(true) > after_time())
4561 {
4562 Matrix(ss_speed, ss_density, 0);
4563 game_pal();
4564 }
4565 9286678 }
4566
4567 708283 void checkQuitKeys()
4568 {
4569 #ifndef ALLEGRO_MACOSX
4570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708283 times.
708283 if(key[KEY_F9]) f_Quit(qRESET);
4571
4572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708283 times.
708283 if(key[KEY_F10]) f_Quit(qEXIT);
4573 #else
4574 if(key[KEY_F7]) f_Quit(qRESET);
4575
4576 if(key[KEY_F8]) f_Quit(qEXIT);
4577 #endif
4578 708283 }
4579
4580 9286678 bool CheatModifierKeys()
4581 {
4582 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4583 // to trigger cheats.
4584
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if (replay_is_replaying())
4585 9286678 return false;
4586
4587 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4588 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4589 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4590 {
4591 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4592 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4593 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4594 {
4595 return true;
4596 }
4597 }
4598 return false;
4599 9286678 }
4600
4601 //99:05:54, for some reason?
4602 #define OLDMAXTIME 21405240
4603 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4604 #define MAXTIME 1944000000
4605
4606 9286804 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4607 {
4608
1/2
✓ Branch 0 taken 9286804 times.
✗ Branch 1 not taken.
9286804 if(zcmusic!=NULL)
4609 {
4610 zcmusic_poll();
4611 }
4612 9286804 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4613
4614 9286804 updatescr(allowwavy);
4615
4616 9286804 Advance=false;
4617
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9286804 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9286804 times.
9286804 while(Paused && !Advance && !Quit)
4618 {
4619 // have to call this, otherwise we'll get an infinite loop
4620 syskeys();
4621 if(allowF6Script)
4622 {
4623 FFCore.runF6Engine();
4624 }
4625 zc_throttle_fps();
4626
4627 #ifdef _WIN32
4628
4629 if(use_dwm_flush)
4630 {
4631 do_DwmFlush();
4632 }
4633
4634 #endif
4635
4636 // to keep music playing
4637 if(zcmusic!=NULL)
4638 {
4639 zcmusic_poll();
4640 }
4641
4642 update_hw_screen();
4643 }
4644
4645
2/2
✓ Branch 0 taken 9286692 times.
✓ Branch 1 taken 112 times.
9286804 if(Quit)
4646 112 return;
4647
4648
3/4
✓ Branch 0 taken 8985563 times.
✓ Branch 1 taken 301129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8985563 times.
9286692 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4649 8985563 game->change_time(1);
4650
4651 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4652
4653 9286692 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4654
2/2
✓ Branch 0 taken 19895 times.
✓ Branch 1 taken 9266797 times.
9286692 if (replay_version_check(0, 16))
4655 9266797 should_reset_down_state = replay_version_check(11, 16);
4656
2/2
✓ Branch 0 taken 6949680 times.
✓ Branch 1 taken 2337012 times.
9286692 if (should_reset_down_state)
4657 {
4658
2/2
✓ Branch 0 taken 42066216 times.
✓ Branch 1 taken 2337012 times.
44403228 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4659 42066216 down_control_states[i] = raw_control_state[i];
4660 2337012 }
4661
4662
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9286678 times.
9286692 if (replay_is_active())
4663 {
4664
2/2
✓ Branch 0 taken 1270449 times.
✓ Branch 1 taken 8016229 times.
9286678 if (replay_version_check(3))
4665 8016229 replay_poll();
4666
4667
4/4
✓ Branch 0 taken 6946098 times.
✓ Branch 1 taken 2340580 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 6845563 times.
9286678 if (replay_version_check(11) || replay_version_check(6, 8))
4668 2441115 replay_peek_input();
4669 9286678 }
4670
4671 9286692 load_control_called_this_frame = false;
4672
4673 9286692 poll_keyboard();
4674 9286692 update_keys();
4675
4676 9286692 ++frame;
4677
4678
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9286678 times.
9286692 if (replay_is_replaying())
4679 9286678 replay_do_cheats();
4680 9286692 syskeys();
4681
4682 // The mouse variables can change from the mouse thread at anytime during a frame,
4683 // so save the result at the start so that replaying is consistent.
4684 9286692 script_mouse_x = gui_mouse_x();
4685 9286692 script_mouse_y = gui_mouse_y();
4686 9286692 script_mouse_z = mouse_z;
4687 9286692 script_mouse_b = mouse_b;
4688
4689 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4690 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4691 // approach here means it doesn't matter which call adds the cheat.
4692 9286692 cheats_execute_queued();
4693
4694
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9286678 times.
9286692 if (replay_is_replaying())
4695 9286678 replay_peek_quit();
4696
2/2
✓ Branch 0 taken 9286678 times.
✓ Branch 1 taken 14 times.
9286692 if (GameFlags & GAMEFLAG_TRYQUIT)
4697 14 replay_step_quit(0);
4698
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 9283758 times.
9286692 if(allowF6Script)
4699 9283758 FFCore.runF6Engine();
4700
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 9286392 times.
9286692 if (Quit)
4701 300 replay_step_quit(Quit);
4702 // Someday... maybe install a Turbo button here?
4703 9286692 zc_throttle_fps();
4704
4705 #ifdef _WIN32
4706
4707 if(use_dwm_flush)
4708 {
4709 do_DwmFlush();
4710 }
4711
4712 #endif
4713
4714 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4715
2/2
✓ Branch 0 taken 68758 times.
✓ Branch 1 taken 9217934 times.
9286692 if(sfxcleanup)
4716 9217934 sfx_cleanup();
4717
4718 9286692 jit_poll();
4719
4720 #ifdef __EMSCRIPTEN__
4721 // Yield the main thread back to the browser occasionally.
4722 if (is_headless())
4723 {
4724 static int rate = 10000;
4725 static int force_yield = rate;
4726 if (force_yield++ >= rate)
4727 {
4728 force_yield = 0;
4729 emscripten_sleep(0);
4730 }
4731 }
4732 #endif
4733
4734
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9286576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
9286692 static bool test_mode_auto_restart = zc_get_config("zeldadx", "test_mode_auto_restart", false);
4735
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9286692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9286692 if (zqtesting_mode && test_mode_auto_restart)
4736 {
4737 static auto last_write_time = fs::last_write_time(qstpath);
4738 static auto last_check = std::chrono::system_clock::now();
4739
4740 if (std::chrono::system_clock::now() - last_check > 200ms)
4741 {
4742 last_check = std::chrono::system_clock::now();
4743 auto write_time = fs::last_write_time(qstpath);
4744 if (last_write_time != write_time)
4745 {
4746 last_write_time = write_time;
4747 disableClickToFreeze = false;
4748 Quit = qRESET;
4749 replay_quit();
4750 }
4751 }
4752 }
4753 9286804 }
4754
4755 101 void zapout()
4756 {
4757 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4758 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4759
4760 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4761 101 script_drawing_commands.Clear();
4762
4763 // zap out
4764
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=1; i<=24; i++)
4765 {
4766 2424 draw_fuzzy(i);
4767 2424 advanceframe(true);
4768
4769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4770 {
4771 break;
4772 }
4773 2424 }
4774 101 }
4775
4776 101 void zapin()
4777 {
4778 101 FFCore.warpScriptCheck();
4779 101 draw_screen(tmpscr);
4780 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4781 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4782 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4783
4784 // zap out
4785 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4786
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=24; i>=1; i--)
4787 {
4788 2424 draw_fuzzy(i);
4789 2424 advanceframe(true);
4790
4791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4792 {
4793 break;
4794 }
4795 2424 }
4796 101 }
4797
4798
4799 65 void wavyout(bool showhero)
4800 {
4801 65 draw_screen(tmpscr, showhero);
4802 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4803
4804 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4805 65 clear_to_color(wavebuf,0);
4806 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4807
4808 static PALETTE wavepal;
4809
4810 int32_t ofs;
4811 65 int32_t amplitude=8;
4812
4813 65 int32_t wavelength=4;
4814 65 double palpos=0, palstep=4, palstop=126;
4815
4816 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4817
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4818 {
4819
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4820 {
4821 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4822 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4823 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4824 698880 }
4825
4826 2730 palpos+=palstep;
4827
4828
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4829 {
4830 2730 hw_palette = &wavepal;
4831 2730 update_hw_pal = true;
4832 2730 }
4833 else
4834 {
4835 hw_palette = &RAMpal;
4836 update_hw_pal = true;
4837 }
4838
4839
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4840 {
4841
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4842 {
4843 117411840 ofs=0;
4844
4845
4/4
✓ Branch 0 taken 57308160 times.
✓ Branch 1 taken 60103680 times.
✓ Branch 2 taken 28654080 times.
✓ Branch 3 taken 28654080 times.
117411840 if((j<i)&&(j&1))
4846 {
4847 28654080 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4848 28654080 }
4849
4850 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4851 117411840 }
4852 458640 }
4853
4854 2730 advanceframe(true);
4855
4856 // animate_combos();
4857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4858 break;
4859 2730 }
4860
4861 65 destroy_bitmap(wavebuf);
4862 65 }
4863
4864 65 void wavyin()
4865 {
4866 65 draw_screen(tmpscr);
4867 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4868
4869 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4870 65 clear_to_color(wavebuf,0);
4871 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4872
4873 static PALETTE wavepal;
4874
4875 //Breaks dark rooms.
4876 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4877 /*
4878 loadfullpal();
4879 loadlvlpal(DMaps[currdmap].color);
4880 ringcolor(false);
4881 */
4882 65 refreshpal=false;
4883 int32_t ofs;
4884 65 int32_t amplitude=8;
4885 65 int32_t wavelength=4;
4886 65 double palpos=168, palstep=4, palstop=126;
4887
4888 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4889
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4890 {
4891
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4892 {
4893 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4894 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4895 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4896 698880 }
4897
4898 2730 palpos-=palstep;
4899
4900
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4901 {
4902 2730 hw_palette = &wavepal;
4903 2730 update_hw_pal = true;
4904 2730 }
4905 else
4906 {
4907 hw_palette = &RAMpal;
4908 update_hw_pal = true;
4909 }
4910
4911
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4912 {
4913
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4914 {
4915 117411840 ofs=0;
4916
4917
4/4
✓ Branch 0 taken 59404800 times.
✓ Branch 1 taken 58007040 times.
✓ Branch 2 taken 30051840 times.
✓ Branch 3 taken 29352960 times.
117411840 if((j<(167-i))&&(j&1))
4918 {
4919 29352960 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4920 29352960 }
4921
4922 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4923 117411840 }
4924 458640 }
4925
4926 2730 advanceframe(true);
4927 // animate_combos();
4928
4929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4930 break;
4931 2730 }
4932
4933 65 destroy_bitmap(wavebuf);
4934 65 }
4935
4936 2168 void blackscr(int32_t fcnt,bool showsubscr)
4937 {
4938 2168 reset_pal_cycling();
4939 2168 script_drawing_commands.Clear();
4940
4941 2168 FFCore.warpScriptCheck();
4942 2168 bool showtime = game->should_show_time();
4943
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 64970 times.
67138 while(fcnt>0)
4944 {
4945 64970 clear_bitmap(framebuf);
4946
4947
2/2
✓ Branch 0 taken 25080 times.
✓ Branch 1 taken 39890 times.
64970 if(showsubscr)
4948 {
4949 39890 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4950
3/4
✓ Branch 0 taken 39890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 39140 times.
39890 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4951 {
4952 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4953 750 }
4954 39890 }
4955
4956 64970 advanceframe(true);
4957
4958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64970 times.
64970 if(Quit)
4959 break;
4960
4961 64970 --fcnt;
4962 }
4963 2168 }
4964
4965 1012 void openscreen(int32_t shape)
4966 {
4967 1012 reset_pal_cycling();
4968 1012 black_opening_count=0;
4969
4970
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 912 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
1012 if(COOLSCROLL || shape>-1)
4971 {
4972 912 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4973 912 return;
4974 }
4975 else
4976 {
4977 100 Hero.setDontDraw(true);
4978 100 show_subscreen_dmap_dots=false;
4979 100 show_subscreen_numbers=false;
4980 // show_subscreen_items=false;
4981 100 show_subscreen_life=false;
4982 }
4983
4984 100 int32_t x=128;
4985
4986 100 FFCore.warpScriptCheck();
4987
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8000 times.
8100 for(int32_t i=0; i<80; i++)
4988 {
4989 8000 draw_screen(tmpscr);
4990 //? draw_screen already draws the subscreen -DD
4991 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4992 8000 x=128-(((i*128/80)/8)*8);
4993
4994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(x>0)
4995 {
4996 8000 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4997 8000 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4998 8000 }
4999
5000 8000 advanceframe(true);
5001
5002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(Quit)
5003 {
5004 break;
5005 }
5006 8000 }
5007
5008 100 Hero.setDontDraw(false);
5009 100 show_subscreen_items=true;
5010 100 show_subscreen_dmap_dots=true;
5011 1012 }
5012
5013 void closescreen(int32_t shape)
5014 {
5015 reset_pal_cycling();
5016 black_opening_count=0;
5017
5018 if(COOLSCROLL || shape>-1)
5019 {
5020 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5021 return;
5022 }
5023 else
5024 {
5025 Hero.setDontDraw(true);
5026 show_subscreen_dmap_dots=false;
5027 show_subscreen_numbers=false;
5028 // show_subscreen_items=false;
5029 show_subscreen_life=false;
5030 }
5031
5032 int32_t x=128;
5033
5034 FFCore.warpScriptCheck();
5035 for(int32_t i=79; i>=0; --i)
5036 {
5037 draw_screen(tmpscr);
5038 //? draw_screen already draws the subscreen -DD
5039 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5040 x=128-(((i*128/80)/8)*8);
5041
5042 if(x>0)
5043 {
5044 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5045 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5046 }
5047
5048 advanceframe(true);
5049
5050 if(Quit)
5051 {
5052 break;
5053 }
5054 }
5055
5056 Hero.setDontDraw(false);
5057 show_subscreen_items=true;
5058 show_subscreen_dmap_dots=true;
5059 }
5060
5061 179 int32_t TriforceCount()
5062 {
5063 179 int32_t c=0;
5064
5065
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5066
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5067 1044 ++c;
5068
5069 179 return c;
5070 }
5071
5072 int32_t onCustomGame()
5073 {
5074 int32_t file = getsaveslot();
5075
5076 if(file < 0)
5077 return D_O_K;
5078
5079 bool ret = (custom_game(file)!=0);
5080 return ret ? D_CLOSE : D_O_K;
5081 }
5082
5083 int32_t onContinue()
5084 {
5085 return D_CLOSE;
5086 }
5087
5088 int32_t onEsc() // Unused?? -L
5089 {
5090 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5091 }
5092
5093 int32_t onVsync()
5094 {
5095 Throttlefps = !Throttlefps;
5096 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5097 return D_O_K;
5098 }
5099
5100 int32_t onWinPosSave()
5101 {
5102 SaveWinPos = !SaveWinPos;
5103 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5104 return D_O_K;
5105 }
5106 int32_t onIntegerScaling()
5107 {
5108 scaleForceInteger = !scaleForceInteger;
5109 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5110 return D_O_K;
5111 }
5112 int32_t onStretchGame()
5113 {
5114 stretchGame = !stretchGame;
5115 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5116 return D_O_K;
5117 }
5118
5119 int32_t onClickToFreeze()
5120 {
5121 ClickToFreeze = !ClickToFreeze;
5122 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5123 return D_O_K;
5124 }
5125
5126 int32_t OnSaveZCConfig()
5127 {
5128 if(jwin_alert3(
5129 "Save Configuration",
5130 "Are you sure that you wish to save your present configuration settings?",
5131 "This will overwrite your prior settings!",
5132 NULL,
5133 "&Yes",
5134 "&No",
5135 NULL,
5136 'y',
5137 'n',
5138 0,
5139 get_zc_font(font_lfont)) == 1)
5140 {
5141 save_game_configs();
5142 return D_O_K;
5143 }
5144 else return D_O_K;
5145 }
5146
5147 int32_t OnnClearQuestDir()
5148 {
5149 if(jwin_alert3(
5150 "Clear Current Directory Cache",
5151 "Are you sure that you wish to clear the current cached directory?",
5152 "This will default the current directory to `<ROOT>/quests` for this instance of ZC Player!",
5153 NULL,
5154 "&Yes",
5155 "&No",
5156 NULL,
5157 'y',
5158 'n',
5159 0,
5160 get_zc_font(font_lfont)) == 1)
5161 {
5162 zc_set_config("zeldadx","quest_dir","");
5163 flush_config_file();
5164 strcpy(qstdir,"");
5165 #ifdef __EMSCRIPTEN__
5166 em_sync_fs();
5167 #endif
5168 return D_O_K;
5169 }
5170 else return D_O_K;
5171 }
5172
5173
5174 int32_t onConsoleZASM()
5175 {
5176 if ( !zasm_debugger )
5177 {
5178 AlertDialog("WARNING: ZASM Debugger",
5179 "Enabling this will open the ZASM Debugger Console"
5180 "\nThis will likely grind ZC to a halt with lag."
5181 "\nTo make any use of this, it is suggested that you read"
5182 "\nthe documentation for 'void Breakpoint(char[] string);'"
5183 " in 'ZScript_Additions.txt'"
5184 "\nThis is not recommended for normal users,"
5185 " and is only intended for ZC developers,"
5186 "\nor quest developers coding directly in ZASM"
5187 "\nAre you sure that you wish to open the ZASM Debugger?",
5188 [&](bool ret,bool)
5189 {
5190 if(ret)
5191 {
5192 FFCore.ZASMPrint(true);
5193 }
5194 }).show();
5195 return D_O_K;
5196 }
5197 else
5198 {
5199 FFCore.ZASMPrint(false);
5200 return D_O_K;
5201 }
5202 }
5203
5204
5205 int32_t onConsoleZScript()
5206 {
5207 if ( !zscript_debugger )
5208 {
5209 AlertDialog("ZScript Debugger",
5210 "Enabling this will open the ZScript Debugger Console"
5211 "\nThis will display any messages logged by scripts,"
5212 " including script errors."
5213 "\nAre you sure that you wish to open the ZScript Debugger?",
5214 [&](bool ret,bool)
5215 {
5216 if(ret)
5217 {
5218 FFCore.ZScriptConsole(true);
5219 }
5220 }).show();
5221 return D_O_K;
5222 }
5223 else
5224 {
5225 FFCore.ZScriptConsole(false);
5226 return D_O_K;
5227 }
5228 }
5229
5230 int32_t onClrConsoleOnReload()
5231 {
5232 clearConsoleOnReload = !clearConsoleOnReload;
5233 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5234 return D_O_K;
5235 }
5236 int32_t onClrConsoleOnLoad()
5237 {
5238 clearConsoleOnLoad = !clearConsoleOnLoad;
5239 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5240 return D_O_K;
5241 }
5242
5243
5244 int32_t onFrameSkip()
5245 {
5246 FrameSkip = !FrameSkip;
5247 return D_O_K;
5248 }
5249
5250 int32_t onSaveDragResize()
5251 {
5252 SaveDragResize = !SaveDragResize;
5253 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5254 return D_O_K;
5255 }
5256
5257 int32_t onDragAspect()
5258 {
5259 DragAspect = !DragAspect;
5260 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5261 return D_O_K;
5262 }
5263
5264 int32_t onTransLayers()
5265 {
5266 TransLayers = !TransLayers;
5267 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5268 return D_O_K;
5269 }
5270
5271 int32_t onNESquit()
5272 {
5273 NESquit = !NESquit;
5274 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5275 return D_O_K;
5276 }
5277
5278 int32_t onVolKeys()
5279 {
5280 volkeys = !volkeys;
5281 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5282 return D_O_K;
5283 }
5284
5285 int32_t onShowFPS()
5286 {
5287 ShowFPS = !ShowFPS;
5288 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5289 return D_O_K;
5290 }
5291
5292 1095828004 bool is_Fkey(int32_t k)
5293 {
5294
2/2
✓ Branch 0 taken 111440136 times.
✓ Branch 1 taken 984387868 times.
1095828004 switch(k)
5295 {
5296 case KEY_F1:
5297 case KEY_F2:
5298 case KEY_F3:
5299 case KEY_F4:
5300 case KEY_F5:
5301 case KEY_F6:
5302 case KEY_F7:
5303 case KEY_F8:
5304 case KEY_F9:
5305 case KEY_F10:
5306 case KEY_F11:
5307 case KEY_F12:
5308 111440136 return true;
5309 }
5310
5311 984387868 return false;
5312 1095828004 }
5313
5314 void kb_getkey(DIALOG *d);
5315
5316 //Used by all keyboard key settings dialogues.
5317 void kb_clearjoystick(DIALOG *d)
5318 {
5319 d->flags|=D_SELECTED;
5320
5321 jwin_button_proc(MSG_DRAW,d,0);
5322 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5323 // text_mode(vc(11));
5324 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5325 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5326
5327 update_hw_screen(true);
5328
5329 clear_keybuf();
5330 int32_t k = next_press_key();
5331 clear_keybuf();
5332
5333 //shnarf
5334 //47=f1
5335 //59=esc
5336 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5337 // *((int32_t*)d->dp3) = k;
5338 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5339
5340
5341 d->flags&=~D_SELECTED;
5342 }
5343
5344 //Clears key to 0.
5345 //Used by all keyboard key settings dialogues.
5346 void kb_clearkey(DIALOG *d);
5347
5348 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5349 {
5350 switch(msg)
5351 {
5352 case MSG_KEY:
5353 case MSG_CLICK:
5354
5355 kb_clearjoystick(d);
5356
5357 while(gui_mouse_b())
5358 {
5359 clear_keybuf();
5360 rest(1);
5361 }
5362
5363 return D_REDRAW;
5364 }
5365
5366 return jwin_button_proc(msg,d,c);
5367 }
5368
5369 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5370 //Only used in keyboard settings dialogues to clear keys.
5371 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5372
5373 int32_t j_getbtn(DIALOG *d)
5374 {
5375 d->flags|=D_SELECTED;
5376 jwin_button_proc(MSG_DRAW,d,0);
5377 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5378 // text_mode(vc(11));
5379 int32_t y = screen->h/2 - 12;
5380 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5381 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5382 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5383
5384 update_hw_screen(true);
5385
5386 int32_t b = next_joy_input(true);
5387 if (b == -2)
5388 return D_CLOSE;
5389
5390 if(b>=0)
5391 *((int32_t*)d->dp3) = b;
5392
5393 d->flags&=~D_SELECTED;
5394
5395 if (player)
5396 player->joy_on = TRUE;
5397
5398 return D_O_K;
5399 }
5400
5401 void j_getstick(DIALOG *d)
5402 {
5403 d->flags|=D_SELECTED;
5404 jwin_button_proc(MSG_DRAW,d,0);
5405 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5406 // text_mode(vc(11));
5407 int32_t y = screen->h/2 - 12;
5408 textout_centre_ex(screen, font, "Move a stick (or DPAD)", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5409 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5410 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5411
5412 update_hw_screen(true);
5413
5414 int32_t b = next_joy_input(false);
5415
5416 if(b>=0)
5417 *((int32_t*)d->dp3) = b;
5418
5419 d->flags&=~D_SELECTED;
5420
5421 if (player)
5422 player->joy_on = TRUE;
5423 }
5424
5425 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5426 {
5427 switch(msg)
5428 {
5429 case MSG_KEY:
5430 case MSG_CLICK:
5431
5432 int ret = j_getbtn(d);
5433 if (ret != D_O_K)
5434 return ret;
5435
5436 while(gui_mouse_b()) {
5437 rest(1);
5438 clear_keybuf();
5439 }
5440
5441 return D_REDRAW;
5442 }
5443
5444 return jwin_button_proc(msg,d,c);
5445 }
5446
5447 int32_t d_jstick_proc(int32_t msg,DIALOG *d,int32_t c)
5448 {
5449 switch(msg)
5450 {
5451 case MSG_KEY:
5452 case MSG_CLICK:
5453
5454 j_getstick(d);
5455
5456 while(gui_mouse_b()) {
5457 rest(1);
5458 clear_keybuf();
5459 }
5460
5461 return D_REDRAW;
5462 }
5463
5464 return jwin_button_proc(msg,d,c);
5465 }
5466
5467 //shnarf
5468 extern const char *key_str[];
5469 std::string get_keystr(int key);
5470
5471 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5472 //extern int32_t zcmusic_bufsz;
5473
5474 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5475 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80],
5476 str_primary_stick[80], str_secondary_stick[80];
5477
5478 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5479 {
5480 //these are here to bypass compiler warnings about unused arguments
5481 c=c;
5482
5483 if (d->w == 1)
5484 {
5485 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
5486 {
5487 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
5488 return D_CLOSE;
5489 }
5490 }
5491
5492 if(msg==MSG_DRAW)
5493 {
5494 switch(d->w)
5495 {
5496 case 0:
5497 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5498 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5499 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5500 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5501 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5502 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5503 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5504 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5505 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5506 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5507 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5508 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5509 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5510 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5511 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5512 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5513 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5514 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5515 break;
5516
5517 case 1:
5518 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5519 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5520 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5521 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5522 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5523 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5524 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5525 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5526 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5527 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5528 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5529 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5530 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5531 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5532 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5533 sprintf(str_primary_stick,"%03d\n%s",js_stick_1_x_stick,joystick_name(js_stick_1_x_stick));
5534 sprintf(str_secondary_stick,"%03d\n%s",js_stick_2_x_stick,joystick_name(js_stick_2_x_stick));
5535 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5536 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5537 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5538 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5539 break;
5540
5541 case 2:
5542 sprintf(str_a," %3d",midi_volume);
5543 sprintf(str_b," %3d",digi_volume);
5544 sprintf(str_l," %3d",emusic_volume);
5545 sprintf(str_m," %3dKB",zcmusic_bufsz);
5546 sprintf(str_r," %3d",sfx_volume);
5547 strcpy(str_s,pan_str[pan_style]);
5548 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5549 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5550 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5551 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5552 break;
5553 }
5554 }
5555
5556 return D_O_K;
5557 }
5558
5559 int32_t set_vol(void *dp3, int32_t d2)
5560 {
5561 switch(((int32_t*)dp3)[0])
5562 {
5563 case 0:
5564 midi_volume = zc_min(d2<<3,255);
5565 break;
5566
5567 case 1:
5568 digi_volume = zc_min(d2<<3,255);
5569 break;
5570
5571 case 2:
5572 emusic_volume = zc_min(d2<<3,255);
5573 break;
5574
5575 case 3:
5576 sfx_volume = zc_min(d2<<3,255);
5577 break;
5578 }
5579
5580 // text_mode(vc(11));
5581 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5582 return D_O_K;
5583 }
5584
5585 int32_t set_pan(void *dp3, int32_t d2)
5586 {
5587 pan_style = vbound(d2,0,3);
5588 // text_mode(vc(11));
5589 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5590 return D_O_K;
5591 }
5592
5593 int32_t set_buf(void *dp3, int32_t d2)
5594 {
5595 // text_mode(vc(11));
5596 zcmusic_bufsz = d2 + 1;
5597 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5598 return D_O_K;
5599 }
5600
5601 static int32_t gamepad_joys_list[] =
5602 {
5603 61,
5604 -1
5605 };
5606
5607 static int32_t gamepad_btn_list[] =
5608 {
5609 6,
5610 7,8,9,10,11,12,13,14,15,16,17,
5611 18,19,20,21,22,23,24,25,26,27,28,
5612 29,30,31,32,33,34,35,36,37,38,39,
5613 -1
5614 };
5615
5616 static int32_t gamepad_dirs_list[] =
5617 {
5618 40,41,42,43,
5619 44,45,46,47,
5620 48,49,50,51,
5621 52,53,54,55,
5622 56,57,58,59,
5623 60,
5624 -1
5625 };
5626
5627 static TABPANEL gamepad_tabs[] =
5628 {
5629 // (text)
5630 { (char *)"Controllers", D_SELECTED, gamepad_joys_list, 0, NULL },
5631 { (char *)"Buttons", 0, gamepad_btn_list, 0, NULL },
5632 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5633 { NULL, 0, NULL, 0, NULL }
5634 };
5635
5636 const char *joy_list(int32_t index, int32_t *list_size)
5637 {
5638 if (index == -1)
5639 {
5640 *list_size = al_get_num_joysticks();
5641 return NULL;
5642 }
5643
5644 ALLEGRO_JOYSTICK* joy = al_get_joystick(index);
5645 if (!joy)
5646 {
5647 return "?";
5648 }
5649
5650 return al_get_joystick_name(joy);
5651 }
5652
5653 116 static ListData joy__list(joy_list, &font);
5654
5655 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c)
5656 {
5657 int32_t d2 = d->d2;
5658 int32_t ret = jwin_droplist_proc(msg,d,c);
5659
5660 if(d2!=d->d2)
5661 {
5662 joystick_index = d->d2;
5663 ret |= D_REDRAW_ALL;
5664 }
5665
5666 return ret;
5667 }
5668
5669 static DIALOG gamepad_dlg[] =
5670 {
5671 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5672 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5673 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5674 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5675 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5676 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5677 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5678 // 6
5679 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5680 // 7
5681 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5682 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5683 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5684 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5685 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5686 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5687 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5688 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5689 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5690 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5691 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5692 // 18
5693 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5694 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5695 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5696 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5697 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5698 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5699 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5700 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5701 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5702 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5703 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5704 // 29
5705 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5706 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5707 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5708 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5709 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5710 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5711 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5712 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5713 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5714 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5715 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5716 // 40
5717 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5718 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5719 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5720 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5721 // 44
5722 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5723 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5724 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5725 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5726 // 48
5727 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5728 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5729 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5730 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5731 // 52
5732 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5733 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5734 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5735 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5736 // 56
5737 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Primary: Use Analog Stick (Ignore above and use below instead)", NULL, NULL },
5738 { d_jstick_proc, 22, 165, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Primary", NULL, &js_stick_1_x_stick },
5739 { d_jstick_proc, 22, 195, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Secondary", NULL, &js_stick_2_x_stick },
5740 { jwin_text_proc, 90, 165, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_primary_stick, NULL, NULL },
5741 { jwin_text_proc, 90, 195, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_secondary_stick, NULL, NULL },
5742
5743 // 61
5744 { d_joylist_proc, 22, 62, 150, 16, 0, 0, 0, 0, 0, 0, (void *) &joy__list, NULL, NULL },
5745
5746 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5747 };
5748
5749 static int32_t keyboard_keys_list[] =
5750 {
5751 6,7,8,9,10,
5752 11,12,13,14,15,16,17,18,19,20,
5753 21,22,23,24,25,26,27,28,29,30,
5754 31,32,33,34,35,36,37,38,39,40,
5755 -1
5756 };
5757
5758 static int32_t keyboard_dirs_list[] =
5759 {
5760 41,42,43,44,
5761 45,46,47,48,
5762 49,50,51,52,
5763 53,54,55,56,
5764 -1
5765 };
5766
5767 static int32_t keyboard_mods_list[] =
5768 {
5769 57,58,59,60,
5770 61,62,63,64,
5771 65,66,67,68,
5772 69,70,71,72,
5773 -1
5774 };
5775
5776 static TABPANEL keyboard_control_tabs[] =
5777 {
5778 // (text)
5779 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5780 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5781 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5782 { NULL, 0, NULL, 0, NULL }
5783 };
5784
5785 static DIALOG keyboard_control_dlg[] =
5786 {
5787 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5788 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5789 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5790 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5791 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5792 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5793 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5794 // Keys
5795 // 6
5796 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5797 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5798 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5799 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5800 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5801 // 11
5802 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5803 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5804 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5805 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5806 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5807 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5808 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5809 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5810 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5811 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5812 // 21
5813 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5814 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5815 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5816 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5817 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5818 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5819 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5820 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5821 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5822 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5823 // 31
5824 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5825 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5826 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5827 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5828 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5829 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5830 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5831 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5832 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5833 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5834 // Dirs
5835 // 41
5836 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5837 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5838 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5839 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5840 // 45
5841 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5842 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5843 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5844 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5845 // 49
5846 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5847 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5848 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5849 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5850 // 53
5851 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5852 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5853 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5854 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5855 // Mods
5856 // 57
5857 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5858 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5859 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5860 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5861 // 61
5862 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5863 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5864 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5865 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5866 // 65
5867 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5868 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5869 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5870 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5871 // 69
5872 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5873 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5874 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5875 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5876 // 73
5877 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5878 };
5879
5880 /*
5881 int32_t midi_dp[3] = {0,147,104};
5882 int32_t digi_dp[3] = {1,147,120};
5883 int32_t pan_dp[3] = {0,147,136};
5884 int32_t buf_dp[3] = {0,147,152};
5885 */
5886 int32_t midi_dp[3] = {0,0,0};
5887 int32_t digi_dp[3] = {1,0,0};
5888 int32_t emus_dp[3] = {2,0,0};
5889 int32_t buf_dp[3] = {0,0,0};
5890 int32_t sfx_dp[3] = {3,0,0};
5891 int32_t pan_dp[3] = {0,0,0};
5892
5893 static DIALOG sound_dlg[] =
5894 {
5895 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5896 116 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5897 116 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5898 116 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5899 116 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5900 116 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5901 116 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5902 116 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5903 116 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5904 116 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5905 116 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5906 // 10
5907 116 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5908 116 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5909 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5910 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5911 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5912 116 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5913 116 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5914 116 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5915 116 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5916 116 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5917 //20
5918 116 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5919 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5920 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5921 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5922 116 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5923 116 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5924 116 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5925 116 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5926 116 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5927 116 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5928 //30
5929 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5930 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5931 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5932 116 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5933 };
5934
5935 char zc_builddate[80];
5936 char zc_aboutstr[80];
5937
5938 static DIALOG about_dlg[] =
5939 {
5940 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5941 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5942 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5943 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5944 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5945 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5946 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5947 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5948 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5949 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5950 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5951 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5952 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5953 };
5954
5955
5956 static DIALOG quest_dlg[] =
5957 {
5958 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5959 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5960 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5961 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5962 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5963 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5964 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5965 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5966 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5967 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5968 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5969 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5970 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5971 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5972 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5973 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5974 };
5975
5976 static DIALOG triforce_dlg[] =
5977 {
5978 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5979 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5980 // 1
5981 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5982 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5983 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5984 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5985 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5986 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5987 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5988 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5989 // 9
5990 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5991 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5992 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5993 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5994 };
5995
5996 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5997 {
5998 go();
5999 int32_t ret=0;
6000 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6001 comeback();
6002 return ret != 0;
6003 }
6004
6005
6006 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6007 {
6008 if(def!=modulepath)
6009 strcpy(modulepath,def);
6010
6011 if(!usefilename)
6012 {
6013 int32_t i=(int32_t)strlen(modulepath);
6014
6015 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6016 modulepath[i--]=0;
6017 }
6018
6019 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6020 int32_t ret=0;
6021 int32_t sel=0;
6022
6023 if(list==NULL)
6024 {
6025 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
6026 }
6027 else
6028 {
6029 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
6030 }
6031
6032 return ret!=0;
6033 }
6034
6035 int32_t onToggleRecordingNewSaves()
6036 {
6037 if (zc_get_config("zeldadx", "replay_new_saves", false))
6038 {
6039 zc_set_config("zeldadx", "replay_new_saves", false);
6040 }
6041 else
6042 {
6043 zc_set_config("zeldadx", "replay_new_saves", true);
6044 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6045 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6046 }
6047 return D_O_K;
6048 }
6049
6050 int32_t onToggleSnapshotAllFrames()
6051 {
6052 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6053 return D_O_K;
6054 }
6055
6056 int32_t onStopReplayOrRecord()
6057 {
6058 if (replay_is_replaying())
6059 {
6060 replay_quit();
6061 }
6062 else if (replay_get_mode() == ReplayMode::Record)
6063 {
6064 if (!replay_get_meta_bool("test_mode"))
6065 {
6066 jwin_alert("Recording", "You cannot stop recording a save file.",
6067 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6068 return D_CLOSE;
6069 }
6070
6071 if (jwin_alert("Stop Recording",
6072 "Save replay to disk and stop recording?",
6073 "This will stop the recording.",
6074 NULL,
6075 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6076 return D_CLOSE;
6077
6078 replay_save();
6079 replay_stop();
6080 }
6081 return D_O_K;
6082 }
6083
6084 static int32_t handle_on_load_replay(ReplayMode mode)
6085 {
6086 if (Playing)
6087 {
6088 if (jwin_alert("Replay - Warning!",
6089 "Loading a replay will exit the current game.",
6090 "All unsaved progress will be lost.",
6091 "Do you wish to continue?",
6092 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6093 return D_CLOSE;
6094 }
6095
6096 std::string mode_string = replay_mode_to_string(mode);
6097 mode_string[0] = std::toupper(mode_string[0]);
6098
6099 std::string line_1 = "Select a replay file to play back.";
6100 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6101 std::string line_3 = "You can stop the replay and take over manually any time.";
6102 if (mode == ReplayMode::Update)
6103 {
6104 line_1 = "Select a replay file to update.";
6105 line_2 = "WARNING: be sure to back up the zplay file";
6106 line_3 = "and verify that the updated replay works as expected!";
6107 }
6108
6109 if (jwin_alert(mode_string.c_str(),
6110 line_1.c_str(),
6111 line_2.c_str(),
6112 line_3.c_str(),
6113 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6114 {
6115 char replay_path[2048];
6116 strcpy(replay_path, "replays/");
6117 if (jwin_file_select_ex(
6118 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6119 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6120 return D_CLOSE;
6121
6122 replay_quit();
6123 load_replay_file_deferred(mode, replay_path);
6124 Quit = qRESET;
6125 return D_CLOSE;
6126 }
6127 return D_O_K;
6128 }
6129
6130 int32_t onLoadReplay()
6131 {
6132 return handle_on_load_replay(ReplayMode::Replay);
6133 }
6134
6135 int32_t onLoadReplayAssert()
6136 {
6137 return handle_on_load_replay(ReplayMode::Assert);
6138 }
6139
6140 int32_t onLoadReplayUpdate()
6141 {
6142 return handle_on_load_replay(ReplayMode::Update);
6143 }
6144
6145 int32_t onSaveReplay()
6146 {
6147 if (replay_get_mode() == ReplayMode::Record)
6148 {
6149 if (!replay_get_meta_bool("test_mode"))
6150 {
6151 if (jwin_alert("Save Replay",
6152 "This will save a copy of the replay up to this point.",
6153 "The official replay file will be untouched.",
6154 "Do you wish to continue?",
6155 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6156 return D_CLOSE;
6157
6158 char replay_path[2048];
6159 strcpy(replay_path, replay_get_replay_path().string().c_str());
6160 if (jwin_file_select_ex(
6161 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6162 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6163 return D_CLOSE;
6164
6165 if (fileexists(replay_path))
6166 {
6167 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6168 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6169 return D_CLOSE;
6170 }
6171
6172 replay_save(replay_path);
6173 }
6174 else
6175 {
6176 replay_save();
6177 }
6178 }
6179 return D_O_K;
6180 }
6181
6182 static MENU replay_menu[] =
6183 {
6184 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6185 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6186 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6187 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6188 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6189 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6190 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6191
6192 { NULL, NULL, NULL, 0, NULL }
6193 };
6194
6195 static DIALOG credits_dlg[] =
6196 {
6197 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6198 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6199 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6200 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6201 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6202 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6203 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6204 };
6205
6206 116 static ListData dmap_list(dmaplist, &font);
6207
6208 static DIALOG goto_dlg[] =
6209 {
6210 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6211 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6212 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6213 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6214 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6215 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6216 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6217 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6218 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6219 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6220 };
6221
6222 int32_t onGoTo()
6223 {
6224 bool music = false;
6225 music = music;
6226 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6227
6228 goto_dlg[0].dp2=get_zc_font(font_lfont);
6229 goto_dlg[4].d2=cheat_goto_dmap;
6230 goto_dlg[6].dp=cheat_goto_screen_str;
6231
6232 clear_keybuf();
6233
6234 large_dialog(goto_dlg);
6235
6236 if(do_zqdialog(goto_dlg,4)==1)
6237 {
6238 // dmap, screen
6239 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6240 };
6241
6242 return D_O_K;
6243 }
6244
6245 int32_t onGoToComplete()
6246 {
6247 if(!Playing)
6248 {
6249 return D_O_K;
6250 }
6251
6252 enter_sys_pal();
6253 music_pause();
6254 pause_all_sfx();
6255 onGoTo();
6256 eat_buttons();
6257
6258 zc_readrawkey(KEY_ESC);
6259
6260 exit_sys_pal();
6261 music_resume();
6262 resume_all_sfx();
6263 return D_O_K;
6264 }
6265
6266 int32_t onCredits()
6267 {
6268 return D_O_K;
6269 }
6270
6271 const char *midilist(int32_t index, int32_t *list_size)
6272 {
6273 if(index<0)
6274 {
6275 *list_size=0;
6276
6277 for(int32_t i=0; i<MAXMIDIS; i++)
6278 if(tunes[i].data)
6279 ++(*list_size);
6280
6281 return NULL;
6282 }
6283
6284 int32_t i=0,m=0;
6285
6286 while(m<=index && i<=MAXMIDIS)
6287 {
6288 if(tunes[i].data)
6289 ++m;
6290
6291 ++i;
6292 }
6293
6294 --i;
6295
6296 if(i==MAXMIDIS && m<index)
6297 return "(null)";
6298
6299 return tunes[i].title;
6300 }
6301
6302 /* ------- MIDI info stuff -------- */
6303
6304 char *text;
6305 midi_info *zmi;
6306 bool dialog_running;
6307 bool listening;
6308
6309 void get_info(int32_t index);
6310
6311 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6312 {
6313 int32_t d2 = d->d2;
6314 int32_t ret = jwin_droplist_proc(msg,d,c);
6315
6316 if(d2!=d->d2)
6317 {
6318 get_info(d->d2);
6319 }
6320
6321 return ret;
6322 }
6323
6324 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6325 {
6326 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6327
6328 int32_t ret = jwin_button_proc(msg,d,c);
6329
6330 if(ret == D_CLOSE)
6331 {
6332 // get current midi index
6333 int32_t index = (d+(d->d1))->d2;
6334 int32_t i=0, m=0;
6335
6336 while(m<=index && i<=MAXMIDIS)
6337 {
6338 if(tunes[i].data)
6339 ++m;
6340
6341 ++i;
6342 }
6343
6344 --i;
6345 jukebox(i);
6346 listening = true;
6347 ret = D_O_K;
6348 }
6349
6350 return ret;
6351 }
6352
6353 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6354 {
6355 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6356
6357 int32_t ret = jwin_button_proc(msg,d,c);
6358
6359 if(ret == D_CLOSE)
6360 {
6361 // get current midi index
6362 int32_t index = (d+(d->d1))->d2;
6363 int32_t i=0, m=0;
6364
6365 while(m<=index && i<=MAXMIDIS)
6366 {
6367 if(tunes[i].data)
6368 ++m;
6369
6370 ++i;
6371 }
6372
6373 --i;
6374
6375 // get file name
6376
6377 int32_t sel=0;
6378 //struct ffblk f;
6379 char title[40] = "Save MIDI: ";
6380 char fname[2048];
6381 memset(fname,0,2048);
6382 static EXT_LIST list[] =
6383 {
6384 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6385 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6386 { NULL, NULL }
6387 };
6388
6389 strcpy(title+11, tunes[i].title);
6390 title[39] = '\0';
6391
6392 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6393 goto done;
6394
6395 if(exists(fname))
6396 {
6397 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6398 goto done;
6399 }
6400
6401 // save midi i
6402
6403 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6404 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6405
6406 done:
6407 chop_path(fname);
6408 ret = D_REDRAW;
6409 }
6410
6411 return ret;
6412 }
6413
6414 116 static ListData midi_list(midilist, &font);
6415
6416 static DIALOG midi_dlg[] =
6417 {
6418 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6419 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6420 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6421 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6422 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6423 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6424 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6425 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6426 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6427 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6428 };
6429
6430 void get_info(int32_t index)
6431 {
6432 int32_t i=0, m=0;
6433
6434 while(m<=index && i<=MAXMIDIS)
6435 {
6436 if(tunes[i].data)
6437 ++m;
6438
6439 ++i;
6440 }
6441
6442 --i;
6443
6444 if(i==MAXMIDIS && m<index)
6445 strcpy(text,"(null)");
6446 else
6447 {
6448 get_midi_info((MIDI*)tunes[i].data,zmi);
6449 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6450 }
6451
6452 midi_dlg[0].dp2=get_zc_font(font_lfont);
6453 midi_dlg[3].dp = text;
6454 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6455 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6456
6457 if(dialog_running)
6458 {
6459 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6460 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6461 }
6462 }
6463
6464 int32_t onMIDICredits()
6465 {
6466 text = (char*)malloc(4096);
6467 zmi = (midi_info*)malloc(sizeof(midi_info));
6468
6469 if(!text || !zmi)
6470 {
6471 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6472 return D_O_K;
6473 }
6474
6475 bool do_pause_midi = midi_pos >= 0 && currmidi;
6476 auto restore_midi = currmidi;
6477 if(do_pause_midi)
6478 {
6479 paused_midi_pos = midi_pos;
6480 stop_midi();
6481 midi_suspended = midissuspHALTED;
6482 }
6483
6484 midi_dlg[0].dp2=get_zc_font(font_lfont);
6485 midi_dlg[2].d1 = 0;
6486 midi_dlg[2].d2 = 0;
6487 midi_dlg[4].flags = D_EXIT;
6488 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6489
6490 listening = false;
6491 dialog_running=false;
6492 get_info(0);
6493
6494 dialog_running=true;
6495
6496 large_dialog(midi_dlg);
6497
6498 do_zqdialog(midi_dlg,0);
6499 dialog_running=false;
6500
6501 if(listening)
6502 music_stop();
6503
6504 if(do_pause_midi)
6505 {
6506 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6507 midi_suspended = midissuspRESUME;
6508 currmidi = restore_midi;
6509 midi_pos = paused_midi_pos;
6510 }
6511
6512 if(text) free(text);
6513 if(zmi) free(zmi);
6514 return D_O_K;
6515 }
6516
6517 int32_t onAbout()
6518 {
6519 char buf1[80]={0};
6520 std::ostringstream oss;
6521 sprintf(buf1,"%s, Version: %s", ZC_PLAYER_NAME,ZC_PLAYER_V);
6522 oss << buf1 << '\n';
6523 sprintf(buf1, "%s", ALPHA_VER_STR);
6524 oss << buf1 << '\n';
6525 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6526 oss << buf1 << '\n';
6527 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6528 oss << buf1 << '\n';
6529 sprintf(buf1, "Tag: %s", getReleaseTag());
6530 oss << buf1 << '\n';
6531
6532 InfoDialog("About ZC", oss.str()).show();
6533 return D_O_K;
6534 }
6535
6536 int32_t onQuest()
6537 {
6538 char fname[100];
6539 strcpy(fname, get_filename(qstpath));
6540 quest_dlg[0].dp2=get_zc_font(font_lfont);
6541 quest_dlg[1].dp = fname;
6542
6543 if(QHeader.quest_number==0)
6544 sprintf(str_a,"Custom");
6545 else
6546 sprintf(str_a,"%d",QHeader.quest_number);
6547
6548 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6549
6550 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6551 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6552
6553 large_dialog(quest_dlg);
6554
6555 do_zqdialog(quest_dlg, 0);
6556 return D_O_K;
6557 }
6558
6559 void call_vidmode_dlg();
6560 int32_t onVidMode()
6561 {
6562 call_vidmode_dlg();
6563 return D_O_K;
6564 }
6565
6566 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6567 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6568 //Added an extra statement, so that if the key is cleared to 0, the cleared
6569 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6570
6571 void load_ukeys(int32_t* arr)
6572 {
6573 arr[ukey_a] = Akey;
6574 arr[ukey_b] = Bkey;
6575 arr[ukey_s] = Skey;
6576 arr[ukey_l] = Lkey;
6577 arr[ukey_r] = Rkey;
6578 arr[ukey_p] = Pkey;
6579 arr[ukey_ex1] = Exkey1;
6580 arr[ukey_ex2] = Exkey2;
6581 arr[ukey_ex3] = Exkey3;
6582 arr[ukey_ex4] = Exkey4;
6583 arr[ukey_du] = DUkey;
6584 arr[ukey_dd] = DDkey;
6585 arr[ukey_dl] = DLkey;
6586 arr[ukey_dr] = DRkey;
6587 arr[ukey_mod1a] = cheat_modifier_keys[0];
6588 arr[ukey_mod1b] = cheat_modifier_keys[1];
6589 arr[ukey_mod2a] = cheat_modifier_keys[2];
6590 arr[ukey_mod2b] = cheat_modifier_keys[3];
6591 };
6592
6593 static const char* ukey_names[] = {
6594 "A", "B", "Start", "L", "R", "Map",
6595 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6596 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6597 "Cheat Mod R1", "Cheat Mod R2",
6598 };
6599 std::string get_ukey_name(int32_t k)
6600 {
6601 if (k < num_ukey) return ukey_names[k];
6602 return "";
6603 }
6604
6605 int32_t onKeyboard()
6606 {
6607 int32_t a = Akey;
6608 int32_t b = Bkey;
6609 int32_t s = Skey;
6610 int32_t l = Lkey;
6611 int32_t r = Rkey;
6612 int32_t p = Pkey;
6613 int32_t ex1 = Exkey1;
6614 int32_t ex2 = Exkey2;
6615 int32_t ex3 = Exkey3;
6616 int32_t ex4 = Exkey4;
6617 int32_t du = DUkey;
6618 int32_t dd = DDkey;
6619 int32_t dl = DLkey;
6620 int32_t dr = DRkey;
6621 int32_t mod1a = cheat_modifier_keys[0];
6622 int32_t mod1b = cheat_modifier_keys[1];
6623 int32_t mod2a = cheat_modifier_keys[2];
6624 int32_t mod2b = cheat_modifier_keys[3];
6625 bool done=false;
6626 int32_t ret;
6627
6628 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6629
6630 large_dialog(keyboard_control_dlg);
6631
6632 while(!done)
6633 {
6634 ret = do_zqdialog(keyboard_control_dlg,3);
6635
6636 if(ret==3) // OK
6637 {
6638 int32_t ukeys[num_ukey];
6639 load_ukeys(ukeys);
6640 std::vector<std::string> uniqueError;
6641 for(int32_t q = 0; q < num_ukey; ++q)
6642 {
6643 for(int32_t p = q+1; p < num_ukey; ++p)
6644 {
6645 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6646 {
6647 char buf[64];
6648 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6649 std::string str(buf);
6650 uniqueError.push_back(str);
6651 }
6652 }
6653 }
6654 if(uniqueError.size() == 0)
6655 {
6656 done = true;
6657 save_control_configs(true);
6658 }
6659 else
6660 {
6661 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6662 box_out("Cannot have duplicate keybinds!"); box_eol();
6663 for(std::vector<std::string>::iterator it = uniqueError.begin();
6664 it != uniqueError.end(); ++it)
6665 {
6666 box_out((*it).c_str()); box_eol();
6667 }
6668 box_end(true);
6669 }
6670 }
6671 else // Cancel
6672 {
6673 Akey = a;
6674 Bkey = b;
6675 Skey = s;
6676 Lkey = l;
6677 Rkey = r;
6678 Pkey = p;
6679 Exkey1 = ex1;
6680 Exkey2 = ex2;
6681 Exkey3 = ex3;
6682 Exkey4 = ex4;
6683 DUkey = du;
6684 DDkey = dd;
6685 DLkey = dl;
6686 DRkey = dr;
6687 cheat_modifier_keys[0] = mod1a;
6688 cheat_modifier_keys[1] = mod1b;
6689 cheat_modifier_keys[2] = mod2a;
6690 cheat_modifier_keys[3] = mod2b;
6691
6692 done=true;
6693 }
6694
6695 rest(1);
6696 }
6697
6698 return D_O_K;
6699 }
6700
6701 int32_t onGamepad()
6702 {
6703 if (al_get_num_joysticks() == 0)
6704 {
6705 InfoDialog("ZC", "No gamepads detected.").show();
6706 return D_O_K;
6707 }
6708
6709 int32_t a = Abtn;
6710 int32_t b = Bbtn;
6711 int32_t s = Sbtn;
6712 int32_t l = Lbtn;
6713 int32_t r = Rbtn;
6714 int32_t m = Mbtn;
6715 int32_t p = Pbtn;
6716 int32_t ex1 = Exbtn1;
6717 int32_t ex2 = Exbtn2;
6718 int32_t ex3 = Exbtn3;
6719 int32_t ex4 = Exbtn4;
6720 int32_t up = DUbtn;
6721 int32_t down = DDbtn;
6722 int32_t left = DLbtn;
6723 int32_t right = DRbtn;
6724 int32_t joy = joystick_index;
6725 int32_t stick_1 = js_stick_1_x_stick;
6726 int32_t stick_2 = js_stick_2_x_stick;
6727
6728 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6729 if(analog_movement)
6730 gamepad_dlg[56].flags|=D_SELECTED;
6731 else
6732 gamepad_dlg[56].flags&=~D_SELECTED;
6733
6734 // TODO: should use controller device GUID or name instead of index, otherwise this value is not
6735 // consistent unless exact same number of joysticks is always connected. Name is problematic b/c
6736 // xinput driver doesn't actually get a name (at least, doesn't for my Xbox controller).
6737 // TODO: should store gamepad control mappings per-controller, otherwise switching joystick
6738 // requires remapping every time.
6739 if (joystick_index >= al_get_num_joysticks())
6740 joystick_index = 0;
6741 gamepad_dlg[61].d2 = joystick_index;
6742
6743 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6744 if (!gamepad_dlg_cur_joystick)
6745 {
6746 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6747 return D_CLOSE;
6748 }
6749
6750 large_dialog(gamepad_dlg);
6751
6752 int32_t ret = do_zqdialog(gamepad_dlg,4);
6753
6754 if(ret == 4) //OK
6755 {
6756 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6757 joystick_index = gamepad_dlg[61].d2;
6758 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6759 if (!gamepad_dlg_cur_joystick)
6760 {
6761 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6762 return D_CLOSE;
6763 }
6764 js_stick_1_y_stick = js_stick_1_x_stick;
6765 js_stick_2_y_stick = js_stick_2_x_stick;
6766 save_control_configs(false);
6767 }
6768 else //Cancel
6769 {
6770 Abtn = a;
6771 Bbtn = b;
6772 Sbtn = s;
6773 Lbtn = l;
6774 Rbtn = r;
6775 Mbtn = m;
6776 Pbtn = p;
6777 Exbtn1 = ex1;
6778 Exbtn2 = ex2;
6779 Exbtn3 = ex3;
6780 Exbtn4 = ex4;
6781 DUbtn = up;
6782 DDbtn = down;
6783 DLbtn = left;
6784 DRbtn = right;
6785 joystick_index = joy;
6786 js_stick_1_x_stick = stick_1;
6787 js_stick_2_x_stick = stick_2;
6788 }
6789
6790 return D_O_K;
6791 }
6792
6793 int32_t onCheatKeys()
6794 {
6795 int32_t oldcheats[Cheat::Last][2];
6796 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6797
6798 bool done=false;
6799
6800 while(!done)
6801 {
6802 bool confirm = false;
6803 CheatKeysDialog(&confirm).show();
6804 if(confirm) // OK
6805 {
6806 std::vector<std::string> uniqueError;
6807 char buf[512];
6808 for(size_t q = 1; q < Cheat::Last; ++q)
6809 {
6810 if(cheatkeys[q][1] && !cheatkeys[q][0])
6811 {
6812 cheatkeys[q][0] = cheatkeys[q][1];
6813 cheatkeys[q][1] = 0;
6814 }
6815 }
6816 for(size_t q = 1; q < Cheat::Last; ++q)
6817 {
6818 if(!bindable_cheat((Cheat)q)) continue;
6819 for(size_t p = q+1; p < Cheat::Last; ++p)
6820 {
6821 if(!bindable_cheat((Cheat)p)) continue;
6822 for(size_t q2 = 0; q2 <= 1; ++q2)
6823 for(size_t p2 = 0; p2 <= 1; ++p2)
6824 {
6825 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6826 {
6827 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6828 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6829 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6830 get_keystr(cheatkeys[q][q2])));
6831 }
6832 }
6833 }
6834 }
6835 if(uniqueError.size() == 0)
6836 {
6837 done = true;
6838 save_cheatkeys();
6839 }
6840 else
6841 {
6842 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6843 box_out("Cannot have duplicate keybinds!"); box_eol();
6844 for(std::vector<std::string>::iterator it = uniqueError.begin();
6845 it != uniqueError.end(); ++it)
6846 {
6847 box_out((*it).c_str()); box_eol();
6848 }
6849 box_end(true);
6850 }
6851 }
6852 else // Cancel
6853 {
6854 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6855 done=true;
6856 }
6857 rest(1);
6858 }
6859
6860 return D_O_K;
6861 }
6862
6863 int32_t onSound()
6864 {
6865 if (get_qr(qr_OLD_SCRIPT_VOLUME))
6866 {
6867 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
6868 {
6869 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
6870 }
6871 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
6872 {
6873 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
6874 }
6875 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
6876 {
6877 emusic_volume = (int32_t)FFCore.usr_music_volume;
6878 }
6879 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
6880 {
6881 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6882 }
6883 }
6884 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6885 {
6886 pan_style = (int32_t)FFCore.usr_panstyle;
6887 }
6888
6889 int32_t m = midi_volume;
6890 int32_t d = digi_volume;
6891 int32_t e = emusic_volume;
6892 int32_t b = zcmusic_bufsz;
6893 int32_t s = sfx_volume;
6894 int32_t p = pan_style;
6895 pan_style = vbound(pan_style,0,3);
6896
6897 sound_dlg[0].dp2=get_zc_font(font_lfont);
6898
6899 large_dialog(sound_dlg);
6900
6901 midi_dp[1] = sound_dlg[6].x;
6902 midi_dp[2] = sound_dlg[6].y;
6903 digi_dp[1] = sound_dlg[7].x;
6904 digi_dp[2] = sound_dlg[7].y;
6905 emus_dp[1] = sound_dlg[8].x;
6906 emus_dp[2] = sound_dlg[8].y;
6907 buf_dp[1] = sound_dlg[9].x;
6908 buf_dp[2] = sound_dlg[9].y;
6909 sfx_dp[1] = sound_dlg[10].x;
6910 sfx_dp[2] = sound_dlg[10].y;
6911 pan_dp[1] = sound_dlg[11].x;
6912 pan_dp[2] = sound_dlg[11].y;
6913 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6914 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6915 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6916 sound_dlg[18].d2 = zcmusic_bufsz;
6917 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6918 sound_dlg[20].d2 = pan_style;
6919
6920 int32_t ret = do_zqdialog(sound_dlg,1);
6921
6922 if(ret==2)
6923 {
6924 master_volume(digi_volume,midi_volume);
6925 if (zcmusic)
6926 zcmusic_set_volume(zcmusic, emusic_volume);
6927
6928 int32_t temp_volume = sfx_volume;
6929 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
6930 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
6931 for(int32_t i=0; i<WAV_COUNT; ++i)
6932 {
6933 //allegro assertion fails when passing in -1 as voice -DD
6934 if(sfx_voice[i] > 0)
6935 voice_set_volume(sfx_voice[i], temp_volume);
6936 }
6937 zc_set_config(sfx_sect,"digi",digi_volume);
6938 zc_set_config(sfx_sect,"midi",midi_volume);
6939 zc_set_config(sfx_sect,"sfx",sfx_volume);
6940 zc_set_config(sfx_sect,"emusic",emusic_volume);
6941 zc_set_config(sfx_sect,"pan",pan_style);
6942 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6943 }
6944 else
6945 {
6946 midi_volume = m;
6947 digi_volume = d;
6948 emusic_volume = e;
6949 zcmusic_bufsz = b;
6950 sfx_volume = s;
6951 pan_style = p;
6952 }
6953
6954 return D_O_K;
6955 }
6956
6957 int32_t queding(char const* s1, char const* s2, char const* s3)
6958 {
6959 return jwin_alert("ZQuest Classic",s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6960 }
6961
6962 int32_t onQuit()
6963 {
6964 if(Playing)
6965 {
6966 int32_t ret=0;
6967
6968 if(get_qr(qr_NOCONTINUE))
6969 {
6970 if(standalone_mode)
6971 {
6972 ret=queding("End current game?",
6973 "The continue screen is disabled; the game",
6974 "will be reloaded from the last save.");
6975 }
6976 else
6977 {
6978 ret=queding("End current game?",
6979 "The continue screen is disabled. You will",
6980 "be returned to the file select screen.");
6981 }
6982 }
6983 else
6984 ret=queding("End current game?",NULL,NULL);
6985
6986 if(ret==1)
6987 {
6988 disableClickToFreeze=false;
6989 Quit=qQUIT;
6990
6991 // Trying to evade a door repair charge?
6992 if(repaircharge)
6993 {
6994 game->change_drupy(-repaircharge);
6995 repaircharge=0;
6996 }
6997
6998 return D_CLOSE;
6999 }
7000 }
7001
7002 return D_O_K;
7003 }
7004
7005 int32_t onTryQuitMenu()
7006 {
7007 return onTryQuit(true);
7008 }
7009
7010 int32_t onTryQuit(bool inMenu)
7011 {
7012 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7013 {
7014 if(active_cutscene.can_f6())
7015 {
7016 if(get_qr(qr_OLD_F6))
7017 {
7018 if(inMenu) onQuit();
7019 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
7020 }
7021 else
7022 {
7023 disableClickToFreeze=false;
7024 GameFlags |= GAMEFLAG_TRYQUIT;
7025 }
7026 return D_CLOSE;
7027 }
7028 else active_cutscene.error();
7029 }
7030
7031 return D_O_K;
7032 }
7033
7034 int32_t onReset()
7035 {
7036 if(queding(" Reset system? ",NULL,NULL)==1)
7037 {
7038 disableClickToFreeze=false;
7039 Quit=qRESET;
7040 replay_quit();
7041 return D_CLOSE;
7042 }
7043
7044 return D_O_K;
7045 }
7046
7047 int32_t onExit()
7048 {
7049 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7050 {
7051 Quit=qEXIT;
7052 return D_CLOSE;
7053 }
7054
7055 return D_O_K;
7056 }
7057
7058 int32_t onDebug()
7059 {
7060 if(debug_enabled)
7061 set_debug(!get_debug());
7062 return D_O_K;
7063 }
7064
7065 int32_t onHeartBeep()
7066 {
7067 heart_beep=!heart_beep;
7068 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7069 return D_O_K;
7070 }
7071
7072 int32_t onSaveIndicator()
7073 {
7074 use_save_indicator = use_save_indicator ? 0 : 1;
7075 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7076 return D_O_K;
7077 }
7078
7079 int32_t onEpilepsy()
7080 {
7081 if(jwin_alert3(
7082 "Epilepsy Flash Reduction",
7083 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7084 "Disabling this will restore standard flash and wavy behaviour.",
7085 "Proceed?",
7086 "&Yes",
7087 "&No",
7088 NULL,
7089 'y',
7090 'n',
7091 0,
7092 get_zc_font(font_lfont)) == 1)
7093 {
7094 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7095 zc_set_config("zeldadx","checked_epilepsy",1);
7096 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7097 }
7098 return D_O_K;
7099 }
7100
7101 bool rc = false;
7102
7103 static DIALOG getnum_dlg[] =
7104 {
7105 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7106 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7107 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7108 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7109 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7110 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7111 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7112 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7113 };
7114
7115 int32_t getnumber(const char *prompt,int32_t initialval)
7116 {
7117 char buf[20];
7118 sprintf(buf,"%d",initialval);
7119 getnum_dlg[0].dp=(void *)prompt;
7120 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7121 getnum_dlg[2].dp=buf;
7122
7123 large_dialog(getnum_dlg);
7124
7125 if(do_zqdialog(getnum_dlg,2)==3)
7126 return atoi(buf);
7127
7128 return initialval;
7129 }
7130
7131 int32_t onLife()
7132 {
7133 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7134 cheats_enqueue(Cheat::Life, value);
7135 return D_O_K;
7136 }
7137
7138 int32_t onHeartC()
7139 {
7140 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7141 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7142 cheats_enqueue(Cheat::MaxLife, max_life);
7143 cheats_enqueue(Cheat::Life, life);
7144 return D_O_K;
7145 }
7146
7147 int32_t onMagicC()
7148 {
7149 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7150 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,max_magic/game->get_mp_per_block())*game->get_mp_per_block();
7151 cheats_enqueue(Cheat::MaxMagic, max_magic);
7152 cheats_enqueue(Cheat::Magic, magic);
7153 return D_O_K;
7154 }
7155
7156 int32_t onRupies()
7157 {
7158 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7159 cheats_enqueue(Cheat::Rupies, value);
7160 return D_O_K;
7161 }
7162
7163 int32_t onMaxBombs()
7164 {
7165 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7166 cheats_enqueue(Cheat::MaxBombs, value);
7167 cheats_enqueue(Cheat::Bombs, value);
7168 return D_O_K;
7169 }
7170
7171 int32_t onRefillLife()
7172 {
7173 cheats_enqueue(Cheat::Life, game->get_maxlife());
7174 return D_O_K;
7175 }
7176 int32_t onRefillMagic()
7177 {
7178 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7179 return D_O_K;
7180 }
7181 int32_t onClock()
7182 {
7183 cheats_enqueue(Cheat::Clock);
7184 return D_O_K;
7185 }
7186
7187 int32_t onQstPath()
7188 {
7189 char path[2048];
7190
7191 chop_path(qstdir);
7192 strcpy(path,qstdir);
7193
7194 go();
7195
7196 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7197 {
7198 chop_path(path);
7199 fix_filename_case(path);
7200 fix_filename_slashes(path);
7201 strcpy(qstdir,path);
7202 strcpy(qstpath,qstdir);
7203 zc_set_config("zeldadx","quest_dir",qstdir);
7204 flush_config_file();
7205 }
7206
7207 comeback();
7208 return D_O_K;
7209 }
7210
7211 #include "dialog/cheat_dialog.h"
7212 int32_t onCheat()
7213 {
7214 call_setcheat_dialog();
7215 game->set_cheat(maxcheat);
7216 if(cheat) game->did_cheat(true);
7217 return D_O_K;
7218 }
7219
7220 int32_t onCheatRupies()
7221 {
7222 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7223 return D_O_K;
7224 }
7225
7226 int32_t onCheatArrows()
7227 {
7228 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7229 return D_O_K;
7230 }
7231
7232 int32_t onCheatBombs()
7233 {
7234 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7235 return D_O_K;
7236 }
7237
7238 // *** screen saver
7239
7240 9286678 int32_t after_time()
7241 {
7242
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(ss_enable == 0)
7243 return INT_MAX;
7244
7245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
9286678 if(ss_after <= 0)
7246 return 5 * 60;
7247
7248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
9286678 if(ss_after <= 3)
7249 return ss_after * 15 * 60;
7250
7251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
9286678 if(ss_after <= 13)
7252 return (ss_after - 3) * 60 * 60;
7253
7254 9286678 return MAX_IDLE + 1;
7255 9286678 }
7256
7257 static const char *after_str[15] =
7258 {
7259 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7260 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7261 "Never"
7262 };
7263
7264 const char *after_list(int32_t index, int32_t *list_size)
7265 {
7266 if(index < 0)
7267 {
7268 *list_size = 15;
7269 return NULL;
7270 }
7271
7272 return after_str[index];
7273 }
7274
7275 116 static ListData after__list(after_list, &font);
7276
7277 static DIALOG scrsaver_dlg[] =
7278 {
7279 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7280 116 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7281 116 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7282 116 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7283 116 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7284 116 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7285 116 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7286 116 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7287 116 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7288 116 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7289 116 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7290 116 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7291 116 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7292 116 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7293 };
7294
7295 int32_t onScreenSaver()
7296 {
7297 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7298 int32_t oldcfgs[3];
7299 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7300 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7301 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7302
7303 large_dialog(scrsaver_dlg);
7304
7305 int32_t ret = do_zqdialog(scrsaver_dlg,-1);
7306
7307 if(ret == 8 || ret == 9)
7308 {
7309 ss_after = scrsaver_dlg[5].d1;
7310 ss_speed = scrsaver_dlg[6].d2;
7311 ss_density = scrsaver_dlg[7].d2;
7312 if(oldcfgs[0] != ss_after)
7313 zc_set_config(cfg_sect,"ss_after",ss_after);
7314 if(oldcfgs[1] != ss_speed)
7315 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7316 if(oldcfgs[2] != ss_density)
7317 zc_set_config(cfg_sect,"ss_density",ss_density);
7318 }
7319
7320 if(ret == 9)
7321 // preview Screen Saver
7322 {
7323 clear_keybuf();
7324 Matrix(ss_speed, ss_density, 30);
7325 system_pal(true);
7326 sys_mouse();
7327 }
7328
7329 return D_O_K;
7330 }
7331
7332 /***** Menus *****/
7333
7334 static MENU game_menu[] =
7335 {
7336 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7337 { (char *)"", NULL, NULL, 0, NULL },
7338 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7339 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7340 { (char *)"", NULL, NULL, 0, NULL },
7341 #ifdef __EMSCRIPTEN__
7342 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7343 #elif defined(ALLEGRO_MACOSX)
7344 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7345 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7346 #else
7347 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7348 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7349 #endif
7350 { NULL, NULL, NULL, 0, NULL }
7351 };
7352
7353 static MENU snapshot_format_menu[] =
7354 {
7355 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7356 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7357 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7358 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7359 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7360 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7361 { NULL, NULL, NULL, 0, NULL }
7362 };
7363
7364 static MENU controls_menu[] =
7365 {
7366 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7367 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7368 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7369 { NULL, NULL, NULL, 0, NULL }
7370 };
7371
7372 static MENU name_entry_mode_menu[] =
7373 {
7374 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7375 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7376 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7377 { NULL, NULL, NULL, 0, NULL }
7378 };
7379
7380 static void set_controls_menu_active()
7381 {
7382
7383 }
7384
7385 static MENU window_menu[] =
7386 {
7387 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7388 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7389 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7390 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7391 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7392 { NULL, NULL, NULL, 0, NULL }
7393 };
7394 static MENU options_menu[] =
7395 {
7396 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7397 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7398 { "&Window Settings", NULL, window_menu, 0, NULL },
7399 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7400 { "Pause In Background", onPauseInBackground, NULL, 0, NULL },
7401 { NULL, NULL, NULL, 0, NULL }
7402 };
7403 static MENU settings_menu[] =
7404 {
7405 { "&Sound...", onSound, NULL, 0, NULL },
7406 { "C&ontrols", NULL, controls_menu, 0, NULL },
7407 { "", NULL, NULL, 0, NULL },
7408 { "Options", NULL, options_menu, 0, NULL },
7409 { "", NULL, NULL, 0, NULL },
7410 //
7411 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7412 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7413 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7414 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7415 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7416 //
7417 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7418 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7419 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7420 { "", NULL, NULL, 0, NULL },
7421 { "Debu&g", onDebug, NULL, 0, NULL },
7422 //
7423 { NULL, NULL, NULL, 0, NULL }
7424 };
7425
7426
7427 static MENU misc_menu[] =
7428 {
7429 { (char *)"&About...", onAbout, NULL, 0, NULL },
7430 // TODO: re-enable, but: 1) do not use a bitmap thing that is hard to update 2) update names and 3) don't use the Z-word.
7431 { (char *)"&Credits...", onCredits, NULL, D_DISABLED, NULL },
7432 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7433 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7434 { (char *)"", NULL, NULL, 0, NULL },
7435 //5
7436 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7437 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7438 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7439 { (char *)"", NULL, NULL, 0, NULL },
7440 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7441 //10
7442 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7443 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7444 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7445 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7446 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7447 //15
7448 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7449 { NULL, NULL, NULL, 0, NULL }
7450 };
7451
7452 static MENU refill_menu[] =
7453 {
7454 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7455 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7456 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7457 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7458 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7459 { NULL, NULL, NULL, 0, NULL }
7460 };
7461
7462 static MENU show_menu[] =
7463 {
7464 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7465 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7466 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7467 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7468 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7469 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7470 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7471 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7472 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7473 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7474 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7475 { (char *)"", NULL, NULL, 0, NULL },
7476 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7477 { (char *)"", NULL, NULL, 0, NULL },
7478 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7479 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7480 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7481 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7482 { NULL, NULL, NULL, 0, NULL }
7483 };
7484
7485 static MENU cheat_menu[] =
7486 {
7487 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7488 { (char *)"", NULL, NULL, 0, NULL },
7489 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7490 { (char *)"", NULL, NULL, 0, NULL },
7491 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7492 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7493 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7494 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7495 { (char *)"", NULL, NULL, 0, NULL },
7496 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7497 { (char *)"", NULL, NULL, 0, NULL },
7498 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7499 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7500 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7501 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7502 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7503 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7504 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7505 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7506 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7507 { NULL, NULL, NULL, 0, NULL }
7508 };
7509
7510 #if DEVLEVEL > 0
7511 int32_t devLogging();
7512 int32_t devDebug();
7513 int32_t devTimestmp();
7514 #if DEVLEVEL > 1
7515 int32_t setCheat();
7516 #endif //DEVLEVEL > 1
7517 enum
7518 {
7519 dv_log,
7520 // dv_dbg,
7521 dv_tmpstmp,
7522 #if DEVLEVEL > 1
7523 dv_nil,
7524 dv_setcheat,
7525 #endif //DEVLEVEL > 1
7526 dv_max
7527 };
7528 static MENU dev_menu[] =
7529 {
7530 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7531 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7532 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7533 #if DEVLEVEL > 1
7534 { (char *)"", NULL, NULL, 0, NULL },
7535 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7536 #endif //DEVLEVEL > 1
7537 { NULL, NULL, NULL, 0, NULL }
7538 };
7539 int32_t devLogging()
7540 {
7541 dev_logging = !dev_logging;
7542 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7543 return D_O_K;
7544 }
7545 // int32_t devDebug()
7546 // {
7547 // dev_debug = !dev_debug;
7548 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7549 // return D_O_K;
7550 // }
7551 int32_t devTimestmp()
7552 {
7553 dev_timestmp = !dev_timestmp;
7554 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7555 return D_O_K;
7556 }
7557 #if DEVLEVEL > 1
7558 int32_t setCheat()
7559 {
7560 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7561 return D_O_K;
7562 }
7563 #endif //DEVLEVEL > 1
7564 #endif //DEVLEVEL > 0
7565
7566 MENU the_player_menu[] =
7567 {
7568 { (char *)"&Game", NULL, game_menu, 0, NULL },
7569 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7570 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7571 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7572 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7573 #if DEVLEVEL > 0
7574 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7575 #endif
7576 { NULL, NULL, NULL, 0, NULL }
7577 };
7578 int32_t onPauseInBackground()
7579 {
7580 if(jwin_alert3(
7581 "Toggle Pause In Background",
7582 "This action will change whether ZC Player pauses when the window loses focus.",
7583 "",
7584 "Proceed?",
7585 "&Yes",
7586 "&No",
7587 NULL,
7588 'y',
7589 'n',
7590 0,
7591 get_zc_font(font_lfont)) == 1)
7592 {
7593 pause_in_background = pause_in_background ? 0 : 1;
7594 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7595 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7596 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7597 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7598 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7599 }
7600 options_menu[4].flags =(pause_in_background)?D_SELECTED:0;
7601 return D_O_K;
7602 }
7603
7604 int32_t onKeyboardEntry()
7605 {
7606 NameEntryMode=0;
7607 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7608 return D_O_K;
7609 }
7610
7611 int32_t onLetterGridEntry()
7612 {
7613 NameEntryMode=1;
7614 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7615 return D_O_K;
7616 }
7617
7618 int32_t onExtLetterGridEntry()
7619 {
7620 NameEntryMode=2;
7621 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7622 return D_O_K;
7623 }
7624
7625 static BITMAP* oldscreen;
7626 int32_t onFullscreenMenu()
7627 {
7628 // super hacks
7629 screen = oldscreen;
7630 if (onFullscreen() == D_REDRAW)
7631 {
7632 oldscreen = screen;
7633 }
7634 screen = menu_bmp;
7635 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7636 return D_O_K;
7637 }
7638
7639 116 void fix_menu()
7640 {
7641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!debug_enabled)
7642 116 settings_menu[13].text = NULL;
7643 116 }
7644
7645 static DIALOG system_dlg[] =
7646 {
7647 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7648 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7649 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7650 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7651 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7652 #ifndef ALLEGRO_MACOSX
7653 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7654 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7655 #else
7656 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7657 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7658 #endif
7659 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7660 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7661 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7662 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7663 };
7664
7665 void reset_snapshot_format_menu()
7666 {
7667 for(int32_t i=0; i<ssfmtMAX; ++i)
7668 {
7669 snapshot_format_menu[i].flags=0;
7670 }
7671 }
7672
7673 int32_t onSetSnapshotFormat()
7674 {
7675 switch(active_menu->text[1])
7676 {
7677 case 'B': //"&BMP"
7678 SnapshotFormat=0;
7679 break;
7680
7681 case 'G': //"&GIF"
7682 SnapshotFormat=1;
7683 break;
7684
7685 case 'J': //"&JPG"
7686 SnapshotFormat=2;
7687 break;
7688
7689 case 'P': //"&PNG"
7690 SnapshotFormat=3;
7691 break;
7692
7693 case 'C': //"PC&X"
7694 SnapshotFormat=4;
7695 break;
7696
7697 case 'T': //"&TGA"
7698 SnapshotFormat=5;
7699 break;
7700
7701 case 'L': //"&LBM"
7702 SnapshotFormat=6;
7703 break;
7704 }
7705 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7706
7707 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7708 return D_O_K;
7709 }
7710
7711
7712 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7713 {
7714 PALETTE tmp;
7715
7716 for(int32_t i=0; i<256; i++)
7717 {
7718 tmp[i].r=r;
7719 tmp[i].g=g;
7720 tmp[i].b=b;
7721 }
7722
7723 fade_interpolate(src,tmp,dest,pos,from,to);
7724 }
7725
7726 14 void system_pal(bool force)
7727 {
7728
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 if(is_sys_pal && !force) return;
7729 14 is_sys_pal = true;
7730 14 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7731 14 hw_palette = &syspal;
7732 14 update_hw_pal = true;
7733 14 }
7734
7735 static uint32_t entered_sys_pal = 0;
7736 14 void enter_sys_pal()
7737 {
7738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
7739 {
7740 if(entered_sys_pal)
7741 ++entered_sys_pal;
7742 return;
7743 }
7744 14 sys_mouse();
7745 14 system_pal(true);
7746 14 ++entered_sys_pal;
7747 14 }
7748 14 void exit_sys_pal()
7749 {
7750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
7751 {
7752
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
7753 {
7754 14 game_pal();
7755 14 game_mouse();
7756 14 }
7757 14 }
7758 14 }
7759
7760 void switch_out_callback()
7761 {
7762 if (pause_in_background && !MenuOpen)
7763 {
7764 System();
7765 }
7766 }
7767
7768 void switch_in_callback()
7769 {
7770 }
7771
7772 423 void game_pal()
7773 {
7774 423 is_sys_pal = false;
7775 423 entered_sys_pal = 0;
7776 423 hw_palette = &RAMpal;
7777 423 update_hw_pal = true;
7778 423 }
7779
7780 static char bar_str[] = "";
7781
7782 14 void music_pause()
7783 {
7784 //al_pause_duh(tmplayer);
7785 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
7786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(zcmixer->oldtrack)
7787 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
7788 14 zc_midi_pause();
7789 14 }
7790
7791 void music_resume()
7792 {
7793 //al_resume_duh(tmplayer);
7794 zcmusic_pause(zcmusic, ZCM_RESUME);
7795 if (zcmixer->oldtrack)
7796 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
7797 zc_midi_resume();
7798 }
7799
7800 3360 void music_stop()
7801 {
7802 //al_stop_duh(tmplayer);
7803 //unload_duh(tmusic);
7804 //tmusic=NULL;
7805 //tmplayer=NULL;
7806 3360 zcmusic_stop(zcmusic);
7807 3360 zcmusic_unload_file(zcmusic);
7808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360 times.
3360 if (zcmixer->oldtrack)
7809 {
7810 zcmusic_stop(zcmixer->oldtrack);
7811 zcmusic_unload_file(zcmixer->oldtrack);
7812 }
7813 3360 zcmixer->newtrack = NULL;
7814 3360 zc_stop_midi();
7815 3360 currmidi=-1;
7816 3360 }
7817
7818 void System()
7819 {
7820 mouse_down=gui_mouse_b();
7821 music_pause();
7822 pause_all_sfx();
7823 MenuOpen = true;
7824 enter_sys_pal();
7825 // FONT *oldfont=font;
7826 // font=tfont;
7827
7828 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7829 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7830
7831 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7832 #if DEVLEVEL > 1
7833 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7834 #endif
7835 game_menu[3].flags =
7836 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7837 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7838 clear_keybuf();
7839
7840 DIALOG_PLAYER *p;
7841
7842 clear_bitmap(menu_bmp);
7843 oldscreen = screen;
7844 screen = menu_bmp;
7845
7846 p = init_dialog(system_dlg,-1);
7847
7848 // drop the menu on startup if menu button pressed
7849 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7850 simulate_keypress(KEY_G << 8);
7851
7852 do
7853 {
7854 if(handle_close_btn_quit())
7855 break;
7856
7857 rest(17);
7858
7859 if(mouse_down && !gui_mouse_b())
7860 mouse_down=0;
7861
7862 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7863 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
7864 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
7865 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
7866 settings_menu[9].flags = TransLayers?D_SELECTED:0;
7867 settings_menu[10].flags = NESquit?D_SELECTED:0;
7868 settings_menu[11].flags = volkeys?D_SELECTED:0;
7869
7870 window_menu[0].flags = DragAspect?D_SELECTED:0;
7871 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
7872 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
7873 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
7874 window_menu[4].flags = stretchGame?D_SELECTED:0;
7875
7876 options_menu[3].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
7877 options_menu[4].flags = (pause_in_background)?D_SELECTED:0;
7878
7879 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
7880 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
7881 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
7882
7883 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
7884 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
7885 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
7886
7887 bool nocheat = (replay_is_replaying() || !Playing
7888 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7889 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
7890 cheat_menu[0].flags = 0;
7891 refill_menu[4].flags = get_qr(qr_TRUEARROWS) ? 0 : D_DISABLED;
7892 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
7893 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
7894 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
7895 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
7896 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
7897 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
7898 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
7899 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
7900
7901 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
7902 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
7903 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
7904 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
7905 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
7906 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
7907 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
7908 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
7909 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
7910 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
7911 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
7912 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
7913 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
7914 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
7915 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
7916
7917 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
7918 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
7919
7920 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
7921 (char *)"Disable recording new saves" :
7922 (char *)"Enable recording new saves";
7923 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
7924 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
7925 (char *)"Stop recording" :
7926 (char *)"Stop replaying";
7927 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
7928 replay_menu[6].text = replay_is_snapshot_all_frames() ?
7929 (char *)"Disable snapshot all frames" :
7930 (char *)"Enable snapshot all frames";
7931
7932 reset_snapshot_format_menu();
7933 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
7934
7935 if(debug_enabled)
7936 {
7937 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
7938 }
7939
7940 if(gui_mouse_b() && !mouse_down)
7941 break;
7942
7943 // press menu to drop the menu
7944 if(rMbtn())
7945 simulate_keypress(KEY_G << 8);
7946
7947 if(input_idle(true) > after_time())
7948 // run Screeen Saver
7949 {
7950 // Screen saver enabled for now.
7951 clear_keybuf();
7952 Matrix(ss_speed, ss_density, 0);
7953 system_pal(true);
7954 sys_mouse();
7955 broadcast_dialog_message(MSG_DRAW, 0);
7956 }
7957
7958 update_hw_screen();
7959 }
7960 while(update_dialog(p));
7961
7962 screen = oldscreen;
7963
7964 // font=oldfont;
7965 mouse_down=gui_mouse_b();
7966 shutdown_dialog(p);
7967 MenuOpen = false;
7968 if(Quit)
7969 {
7970 kill_sfx();
7971 music_stop();
7972 update_hw_screen();
7973 }
7974 else
7975 {
7976 music_resume();
7977 resume_all_sfx();
7978
7979 if(rc)
7980 ringcolor(false);
7981 }
7982 exit_sys_pal();
7983
7984 eat_buttons();
7985
7986 rc=false;
7987 clear_keybuf();
7988
7989 zc_init_apply_cheat_delta();
7990 }
7991
7992 116 void fix_dialogs()
7993 {
7994 116 jwin_center_dialog(about_dlg);
7995 116 jwin_center_dialog(gamepad_dlg);
7996 116 jwin_center_dialog(credits_dlg);
7997 116 jwin_center_dialog(gamemode_dlg);
7998 116 jwin_center_dialog(getnum_dlg);
7999 116 jwin_center_dialog(goto_dlg);
8000 116 jwin_center_dialog(keyboard_control_dlg);
8001 116 jwin_center_dialog(midi_dlg);
8002 116 jwin_center_dialog(quest_dlg);
8003 116 jwin_center_dialog(scrsaver_dlg);
8004 116 jwin_center_dialog(sound_dlg);
8005 116 jwin_center_dialog(triforce_dlg);
8006
8007 // digi_dp[1] += scrx;
8008 // digi_dp[2] += scry;
8009 // midi_dp[1] += scrx;
8010 // midi_dp[2] += scry;
8011 // pan_dp[1] += scrx;
8012 // pan_dp[2] += scry;
8013 // emus_dp[1] += scrx;
8014 // emus_dp[2] += scry;
8015 // buf_dp[1] += scrx;
8016 // buf_dp[2] += scry;
8017 // sfx_dp[1] += scrx;
8018 // sfx_dp[2] += scry;
8019 116 }
8020
8021 /*****************************/
8022 /**** Custom Sound System ****/
8023 /*****************************/
8024
8025 116 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8026 {
8027
2/4
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
116 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8028 }
8029
8030 // Run an NSF, or a MIDI if the NSF is missing somehow.
8031 149 bool try_zcmusic(const char *filename, int32_t track, int32_t midi, int32_t fadeoutframes)
8032 {
8033 149 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8034
8035 // Found it
8036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(newzcmusic!=NULL)
8037 {
8038 newzcmusic->fadevolume = 10000;
8039 newzcmusic->fadeoutframes = fadeoutframes;
8040
8041 zcmixer->newtrack = newzcmusic;
8042
8043 zcmusic_stop(zcmusic);
8044 zcmusic_unload_file(zcmusic);
8045 zc_stop_midi();
8046
8047 zcmusic=newzcmusic;
8048 int32_t temp_volume = emusic_volume;
8049 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8050 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
8051 temp_volume = (temp_volume * zcmusic->fadevolume) / 10000;
8052 zcmusic_play(zcmusic, temp_volume);
8053
8054 if(track>0)
8055 zcmusic_change_track(zcmusic,track);
8056
8057 return true;
8058 }
8059
8060 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8061
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 70 times.
149 else if(midi>-1000)
8062 70 jukebox(midi);
8063
8064 149 return false;
8065 149 }
8066
8067 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8068 {
8069 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8070 // Found it
8071 if(newzcmusic!=NULL)
8072 {
8073 zcmusic_stop(zcmusic);
8074 zcmusic_unload_file(zcmusic);
8075 zc_stop_midi();
8076
8077 zcmusic=newzcmusic;
8078 zcmusic_play(zcmusic, emusic_volume);
8079
8080 if(track>0)
8081 zcmusic_change_track(zcmusic,track);
8082
8083 return true;
8084 }
8085
8086 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8087 else if(midi>-1000)
8088 jukebox(midi);
8089
8090 return false;
8091 }
8092
8093 int32_t get_zcmusicpos()
8094 {
8095 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8096 return debugtracething;
8097 return 0;
8098 }
8099
8100 void set_zcmusicpos(int32_t position)
8101 {
8102 zcmusic_set_curpos(zcmusic, position);
8103 }
8104
8105 void set_zcmusicspeed(int32_t speed)
8106 {
8107 zcmusic_set_speed(zcmusic, speed);
8108 }
8109
8110 int32_t get_zcmusiclen()
8111 {
8112 return zcmusic_get_length(zcmusic);
8113 }
8114
8115 void set_zcmusicloop(double start, double end)
8116 {
8117 zcmusic_set_loop(zcmusic, start, end);
8118 }
8119
8120 63941 void jukebox(int32_t index,int32_t loop)
8121 {
8122
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if (is_headless())
8123 63941 return;
8124
8125 music_stop();
8126
8127 if(index<0) index=MAXMIDIS-1;
8128
8129 if(index>=MAXMIDIS) index=0;
8130
8131 music_stop();
8132
8133 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8134 // stuck notes when a song stops. This fixes it.
8135 if(strcmp(midi_driver->name, "DIGMID")==0)
8136 zc_set_volume(0, 0);
8137
8138 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
8139 zc_play_midi((MIDI*)tunes[index].data,loop);
8140
8141 if(tunes[index].start>0)
8142 zc_midi_seek(tunes[index].start);
8143
8144 midi_loop_start = tunes[index].loop_start;
8145 midi_loop_end = tunes[index].loop_end;
8146
8147 currmidi=index;
8148 master_volume(digi_volume, midi_volume);
8149 //midi_paused=false;
8150 63941 }
8151
8152 63941 void jukebox(int32_t index)
8153 {
8154
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index<0) index=MAXMIDIS-1;
8155
8156
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index>=MAXMIDIS) index=0;
8157
8158 // do nothing if it's already playing
8159
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63941 if(index==currmidi && midi_pos>=0)
8160 {
8161 return;
8162 }
8163
8164 63941 jukebox(index,tunes[index].loop);
8165 63941 }
8166
8167 16 void play_DmapMusic()
8168 {
8169
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (is_headless())
8170 16 return;
8171
8172 static char tfile[2048];
8173 static int32_t ttrack=0;
8174 bool domidi=false;
8175
8176 int32_t fadeoutframes = 0;
8177 if (zcmusic != NULL)
8178 fadeoutframes = zcmusic->fadeoutframes;
8179
8180 if(DMaps[currdmap].tmusic[0]!=0)
8181 {
8182 if(zcmusic==NULL ||
8183 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8184 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8185 {
8186 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
8187 {
8188 if (FFCore.play_enh_music_crossfade(DMaps[currdmap].tmusic, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
8189 {
8190 if (zcmusic != NULL)
8191 {
8192 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
8193 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8194 }
8195 }
8196 }
8197 else
8198 {
8199 if (zcmusic != NULL)
8200 {
8201 zcmusic_stop(zcmusic);
8202 zcmusic_unload_file(zcmusic);
8203 zcmusic = NULL;
8204 zcmixer->newtrack = NULL;
8205 }
8206
8207 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8208 zcmixer->newtrack = zcmusic;
8209
8210 if (zcmusic != NULL)
8211 {
8212 zc_stop_midi();
8213 strcpy(tfile, DMaps[currdmap].tmusic);
8214 zcmusic_play(zcmusic, emusic_volume);
8215 int32_t temptracks = 0;
8216 temptracks = zcmusic_get_tracks(zcmusic);
8217 temptracks = (temptracks < 2) ? 1 : temptracks;
8218 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8219 zcmusic_change_track(zcmusic, ttrack);
8220 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8221 }
8222 else
8223 {
8224 tfile[0] = 0;
8225 domidi = true;
8226 }
8227 }
8228 }
8229 }
8230 else
8231 {
8232 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8233 {
8234 FFCore.play_enh_music_crossfade(NULL, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8235 }
8236 else
8237 {
8238 domidi = true;
8239 }
8240 }
8241
8242 if(domidi)
8243 {
8244 int32_t m=DMaps[currdmap].midi;
8245
8246 switch(m)
8247 {
8248 case 1:
8249 jukebox(ZC_MIDI_OVERWORLD);
8250 break;
8251
8252 case 2:
8253 jukebox(ZC_MIDI_DUNGEON);
8254 break;
8255
8256 case 3:
8257 jukebox(ZC_MIDI_LEVEL9);
8258 break;
8259
8260 default:
8261 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8262 jukebox(m+MIDIOFFSET_DMAP);
8263 else
8264 music_stop();
8265 }
8266 }
8267 16 }
8268
8269 15754 void playLevelMusic()
8270 {
8271
1/2
✓ Branch 0 taken 15754 times.
✗ Branch 1 not taken.
15754 if (is_headless())
8272 15754 return;
8273
8274 int32_t m=tmpscr->screen_midi;
8275
8276 switch(m)
8277 {
8278 case -2:
8279 music_stop();
8280 break;
8281
8282 case -1:
8283 play_DmapMusic();
8284 break;
8285
8286 case 1:
8287 jukebox(ZC_MIDI_OVERWORLD);
8288 break;
8289
8290 case 2:
8291 jukebox(ZC_MIDI_DUNGEON);
8292 break;
8293
8294 case 3:
8295 jukebox(ZC_MIDI_LEVEL9);
8296 break;
8297
8298 default:
8299 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8300 jukebox(m+MIDIOFFSET_MAPSCR);
8301 else
8302 music_stop();
8303 }
8304 15754 }
8305
8306 116 void master_volume(int32_t dv,int32_t mv)
8307 {
8308
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8309
8310
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8311
8312
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
116 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8313 116 int32_t temp_vol = midi_volume;
8314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8315 116 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8316 116 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8317 116 }
8318
8319 /*****************/
8320 /***** SFX *****/
8321 /*****************/
8322
8323 // array of voices, one for each sfx sample in the data file
8324 // 0+ = voice #
8325 // -1 = voice not allocated
8326 116 void Z_init_sound()
8327 {
8328
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 116 times.
29812 for(int32_t i=0; i<WAV_COUNT; i++)
8329 29696 sfx_voice[i]=-1;
8330
8331 116 const char* midis[ZC_MIDI_COUNT] = {
8332 "assets/dungeon.mid",
8333 "assets/ending.mid",
8334 "assets/gameover.mid",
8335 "assets/level9.mid",
8336 "assets/overworld.mid",
8337 "assets/title.mid",
8338 "assets/triforce.mid",
8339 };
8340
2/2
✓ Branch 0 taken 812 times.
✓ Branch 1 taken 116 times.
928 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8341 {
8342 812 tunes[i].data = load_midi(midis[i]);
8343
1/2
✓ Branch 0 taken 812 times.
✗ Branch 1 not taken.
812 if (!tunes[i].data)
8344 Z_error_fatal("Missing required file %s\n", midis[i]);
8345 812 }
8346
8347
2/2
✓ Branch 0 taken 29232 times.
✓ Branch 1 taken 116 times.
29348 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8348 29232 tunes[ZC_MIDI_COUNT+j].data=NULL;
8349
8350 116 master_volume(digi_volume,midi_volume);
8351 116 }
8352
8353 // returns number of voices currently allocated
8354 int32_t sfx_count()
8355 {
8356 int32_t c=0;
8357
8358 for(int32_t i=0; i<WAV_COUNT; i++)
8359 if(sfx_voice[i]!=-1)
8360 ++c;
8361
8362 return c;
8363 }
8364
8365 // clean up finished samples
8366 9217934 void sfx_cleanup()
8367 {
8368
2/2
✓ Branch 0 taken 2359791104 times.
✓ Branch 1 taken 9217934 times.
2369009038 for(int32_t i=0; i<WAV_COUNT; i++)
8369
3/4
✓ Branch 0 taken 619766 times.
✓ Branch 1 taken 2359171338 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619766 times.
2360410870 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8370 {
8371 619766 deallocate_voice(sfx_voice[i]);
8372 619766 sfx_voice[i]=-1;
8373 619766 }
8374 9217934 }
8375
8376 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8377 // if a voice is already allocated (and/or playing), then it just returns true
8378 // Returns true: voice is allocated
8379 // false: unsuccessful
8380 964184 bool sfx_init(int32_t index)
8381 {
8382 // check index
8383
3/4
✓ Branch 0 taken 721795 times.
✓ Branch 1 taken 242389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721795 times.
964184 if(index<=0 || index>=WAV_COUNT)
8384 242389 return false;
8385
8386
2/2
✓ Branch 0 taken 102011 times.
✓ Branch 1 taken 619784 times.
721795 if(sfx_voice[index]==-1)
8387 {
8388
2/2
✓ Branch 0 taken 209876 times.
✓ Branch 1 taken 409908 times.
619784 if(sfxdat)
8389 {
8390
1/2
✓ Branch 0 taken 209876 times.
✗ Branch 1 not taken.
209876 if(index<Z35)
8391 {
8392 209876 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8393 209876 }
8394 else
8395 {
8396 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8397 }
8398 209876 }
8399 else
8400 {
8401 409908 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8402 }
8403
8404 619784 int32_t temp_volume = sfx_volume;
8405
2/4
✓ Branch 0 taken 619784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 619784 times.
✗ Branch 3 not taken.
619784 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8406 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8407 619784 voice_set_volume(sfx_voice[index], temp_volume);
8408 619784 }
8409
8410 721795 return sfx_voice[index] != -1;
8411 964184 }
8412
8413 int32_t sfx_get_default_freq(int32_t index)
8414 {
8415 if (sfxdat)
8416 {
8417 if (index < Z35)
8418 {
8419 return ((SAMPLE*)sfxdata[index].dat)->freq;
8420 }
8421 else
8422 {
8423 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8424 }
8425 }
8426 else
8427 {
8428 return customsfxdata[index].freq;
8429 }
8430 }
8431
8432 int32_t sfx_get_length(int32_t index)
8433 {
8434 if (sfxdat)
8435 {
8436 if (index < Z35)
8437 {
8438 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8439 }
8440 else
8441 {
8442 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8443 }
8444 }
8445 else
8446 {
8447 return int32_t(customsfxdata[index].len);
8448 }
8449 }
8450
8451 // plays an sfx sample
8452 964184 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8453 {
8454
2/2
✓ Branch 0 taken 721795 times.
✓ Branch 1 taken 242389 times.
964184 if(!sfx_init(index))
8455 242389 return;
8456
1/2
✓ Branch 0 taken 721795 times.
✗ Branch 1 not taken.
721795 if (!is_headless())
8457 {
8458 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8459 voice_set_pan(sfx_voice[index], pan);
8460
8461 // Only used by ZScript currently
8462 if (freq <= -1)
8463 {
8464 freq = sfx_get_default_freq(index);
8465 }
8466 voice_set_frequency(sfx_voice[index], freq);
8467
8468 // Only used by ZScript currently
8469 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8470 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8471 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8472 voice_set_volume(sfx_voice[index], temp_volume);
8473
8474 int32_t pos = voice_get_position(sfx_voice[index]);
8475
8476 if (restart) voice_set_position(sfx_voice[index], 0);
8477
8478 if (pos <= 0)
8479 voice_start(sfx_voice[index]);
8480 }
8481
8482
3/4
✓ Branch 0 taken 398004 times.
✓ Branch 1 taken 323791 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398004 times.
721795 if (restart && replay_is_debug())
8483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398004 times.
398004 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8484 964184 }
8485
8486 // true if sfx is allocated
8487 68052 bool sfx_allocated(int32_t index)
8488 {
8489
3/4
✓ Branch 0 taken 9923 times.
✓ Branch 1 taken 58129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9923 times.
68052 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8490 }
8491
8492 // start it (in loop mode) if it's not already playing,
8493 // otherwise adjust it to play in loop mode -DD
8494 55173 void cont_sfx(int32_t index)
8495 {
8496
1/2
✓ Branch 0 taken 55173 times.
✗ Branch 1 not taken.
55173 if (is_headless())
8497 55173 return;
8498
8499 if(!sfx_init(index))
8500 {
8501 return;
8502 }
8503
8504 if(voice_get_position(sfx_voice[index])<=0)
8505 {
8506 voice_set_position(sfx_voice[index],0);
8507 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8508 voice_start(sfx_voice[index]);
8509 }
8510 else
8511 {
8512 adjust_sfx(index, 128, true);
8513 }
8514 55173 }
8515
8516 // adjust parameters while playing
8517 4075 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8518 {
8519
4/6
✓ Branch 0 taken 2315 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2315 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2315 times.
4075 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8520 4075 return;
8521
8522 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8523 voice_set_pan(sfx_voice[index],pan);
8524 4075 }
8525
8526 // pauses a voice
8527 1725 void pause_sfx(int32_t index)
8528 {
8529
3/6
✓ Branch 0 taken 1725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1725 times.
1725 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8530 voice_stop(sfx_voice[index]);
8531 1725 }
8532
8533 // resumes a voice
8534 747 void resume_sfx(int32_t index)
8535 {
8536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 if (is_headless())
8537 747 return;
8538
8539 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8540 voice_start(sfx_voice[index]);
8541 747 }
8542
8543 // pauses all active voices
8544 452 void pause_all_sfx()
8545 {
8546
2/2
✓ Branch 0 taken 115712 times.
✓ Branch 1 taken 452 times.
116164 for(int32_t i=0; i<WAV_COUNT; i++)
8547
2/2
✓ Branch 0 taken 115711 times.
✓ Branch 1 taken 1 times.
115713 if(sfx_voice[i]!=-1)
8548 1 voice_stop(sfx_voice[i]);
8549 452 }
8550
8551 // resumes all paused voices
8552 438 void resume_all_sfx()
8553 {
8554
2/2
✓ Branch 0 taken 112128 times.
✓ Branch 1 taken 438 times.
112566 for(int32_t i=0; i<WAV_COUNT; i++)
8555
1/2
✓ Branch 0 taken 112128 times.
✗ Branch 1 not taken.
112128 if(sfx_voice[i]!=-1)
8556 voice_start(sfx_voice[i]);
8557 438 }
8558
8559 // stops an sfx and deallocates the voice
8560 7462195 void stop_sfx(int32_t index)
8561 {
8562
3/4
✓ Branch 0 taken 6277129 times.
✓ Branch 1 taken 1185066 times.
✓ Branch 2 taken 6277129 times.
✗ Branch 3 not taken.
7462195 if(index<=0 || index>=WAV_COUNT)
8563 1185066 return;
8564
8565
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6277117 times.
6277129 if(sfx_voice[index]!=-1)
8566 {
8567 12 deallocate_voice(sfx_voice[index]);
8568 12 sfx_voice[index]=-1;
8569 12 }
8570 7462195 }
8571
8572 // Stops SFX played by Hero's item of the given family
8573 128638 void stop_item_sfx(int32_t family)
8574 {
8575 128638 int32_t id=current_item_id(family);
8576
8577
2/2
✓ Branch 0 taken 128083 times.
✓ Branch 1 taken 555 times.
128638 if(id<0)
8578 128083 return;
8579
8580 555 stop_sfx(itemsbuf[id].usesound);
8581 128638 }
8582
8583 3222 void kill_sfx()
8584 {
8585
2/2
✓ Branch 0 taken 824832 times.
✓ Branch 1 taken 3222 times.
828054 for(int32_t i=0; i<WAV_COUNT; i++)
8586
2/2
✓ Branch 0 taken 824826 times.
✓ Branch 1 taken 6 times.
824838 if(sfx_voice[i]!=-1)
8587 {
8588 6 deallocate_voice(sfx_voice[i]);
8589 6 sfx_voice[i]=-1;
8590 6 }
8591 3222 }
8592
8593 659811 int32_t pan(int32_t x)
8594 {
8595
1/4
✓ Branch 0 taken 659811 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
659811 switch(pan_style)
8596 {
8597 case 0:
8598 return 128;
8599
8600 case 1:
8601 659811 return vbound((x>>1)+68,0,255);
8602
8603 case 2:
8604 return vbound(((x*3)>>2)+36,0,255);
8605 }
8606
8607 return vbound(x,0,255);
8608 659811 }
8609
8610 /*******************************/
8611 /******* Input Handlers ********/
8612 /*******************************/
8613
8614 25092836 bool joybtn(int32_t b)
8615 {
8616
1/2
✓ Branch 0 taken 25092836 times.
✗ Branch 1 not taken.
25092836 if(b == 0)
8617 return false;
8618
1/2
✓ Branch 0 taken 25092836 times.
✗ Branch 1 not taken.
25092836 if (b-1 >= joy[joystick_index].num_buttons)
8619 25092836 return false;
8620
8621 return joy[joystick_index].button[b-1].b !=0;
8622 25092836 }
8623
8624 bool joystick(int32_t s)
8625 {
8626 if(s < 0)
8627 return false;
8628 if (s >= joy[joystick_index].num_sticks)
8629 return false;
8630
8631 for (int i = 0; i < joy[joystick_index].stick[s].num_axis; i++)
8632 {
8633 if (joy[joystick_index].stick[s].axis[i].d1 || joy[joystick_index].stick[s].axis[i].d2)
8634 return true;
8635 }
8636 return false;
8637 }
8638
8639 const char* joybtn_name(int32_t b)
8640 {
8641 if (b <= 0 || b > joy[joystick_index].num_buttons)
8642 return "";
8643
8644 return joy[joystick_index].button[b-1].name;
8645 }
8646
8647 const char* joystick_name(int32_t s)
8648 {
8649 if (s < 0 || s >= joy[joystick_index].num_sticks)
8650 return "";
8651
8652 return joy[joystick_index].stick[s].name;
8653 }
8654
8655 int32_t next_press_key();
8656
8657 int32_t next_joy_input(bool buttons)
8658 {
8659 clear_keybuf();
8660
8661 //first, we need to wait until they're pressing no buttons
8662 for(;;)
8663 {
8664 if(keypressed())
8665 {
8666 switch(readkey()>>8)
8667 {
8668 case KEY_ESC:
8669 return -1;
8670
8671 case KEY_SPACE:
8672 return 0;
8673 }
8674 }
8675
8676 poll_joystick();
8677 bool done = true;
8678
8679 if (buttons)
8680 {
8681 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8682 {
8683 if(joybtn(i)) done = false;
8684 }
8685 }
8686 else
8687 {
8688 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8689 {
8690 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8691 return -2;
8692 }
8693 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8694 {
8695 if(joystick(i)) done = false;
8696 }
8697 }
8698
8699 if(done) break;
8700 rest(1);
8701 }
8702
8703 //now, we need to wait for them to press any button
8704 for(;;)
8705 {
8706 if(keypressed())
8707 {
8708 switch(readkey()>>8)
8709 {
8710 case KEY_ESC:
8711 return -1;
8712
8713 case KEY_SPACE:
8714 return 0;
8715 }
8716 }
8717
8718 poll_joystick();
8719
8720 if (buttons)
8721 {
8722 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8723 {
8724 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8725 return -2;
8726 }
8727 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8728 {
8729 if(joybtn(i))
8730 return i;
8731 }
8732 }
8733 else
8734 {
8735 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8736 {
8737 if(joystick(i))
8738 return i;
8739 }
8740 }
8741 rest(1);
8742 }
8743 }
8744
8745 1205771 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8746 {
8747
2/2
✓ Branch 0 taken 1201420 times.
✓ Branch 1 taken 4351 times.
1205771 bool ret = btn && !flag;
8748 1205771 flag = rawbtn;
8749
8750 1205771 return ret;
8751 }
8752 190797304 static bool rButton(bool &btn, bool &flag)
8753 {
8754
2/2
✓ Branch 0 taken 183953390 times.
✓ Branch 1 taken 6843914 times.
190797304 bool ret = btn && !flag;
8755 190797304 flag = btn;
8756
8757 190797304 return ret;
8758 }
8759 2888985 static bool rButtonPeek(bool btn, bool flag)
8760 {
8761
2/2
✓ Branch 0 taken 2685887 times.
✓ Branch 1 taken 203098 times.
2888985 if(!btn)
8762 {
8763 2685887 return false;
8764 }
8765
2/2
✓ Branch 0 taken 17939 times.
✓ Branch 1 taken 185159 times.
203098 else if(!flag)
8766 {
8767 17939 return true;
8768 }
8769
8770 185159 return false;
8771 2888985 }
8772
8773 // Updated only by keyboard/gamepad.
8774 // If in replay mode, this is set directly by the replay system.
8775 // This should never be read from directly - use control_state instead.
8776 bool raw_control_state[ZC_CONTROL_STATES];
8777
8778 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8779 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8780 // lasts until the next call to load_control_state.
8781 bool control_state[ZC_CONTROL_STATES];
8782 bool disable_control[ZC_CONTROL_STATES];
8783 bool drunk_toggle_state[11];
8784 bool disabledKeys[127];
8785 bool KeyInput[127];
8786 bool KeyPress[127];
8787
8788 bool key_current_frame[127];
8789 bool key_previous_frame[127];
8790
8791 static bool key_system[127];
8792 static bool key_system_previous[127];
8793 static bool key_system_press[127];
8794
8795 bool button_press[ZC_CONTROL_STATES];
8796 bool button_hold[ZC_CONTROL_STATES];
8797
8798 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8799 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8800 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8801 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8802 #define STICK_PRECISION 56 //define your own sensitivity
8803
8804 7800709 void load_control_state()
8805 {
8806 7800709 load_control_called_this_frame = true;
8807
8808
2/2
✓ Branch 0 taken 4833196 times.
✓ Branch 1 taken 2967513 times.
7800709 if (replay_version_check(8, 11))
8809 {
8810
2/2
✓ Branch 0 taken 53415234 times.
✓ Branch 1 taken 2967513 times.
56382747 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8811 53415234 down_control_states[i] = raw_control_state[i];
8812 2967513 }
8813
8814
1/2
✓ Branch 0 taken 7800709 times.
✗ Branch 1 not taken.
7800709 if (!replay_is_replaying())
8815 {
8816 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8817 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8818 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8819 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8820 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8821 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8822 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8823 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8824 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8825 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8826 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8827 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8828 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8829 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8830
8831 if(num_joysticks != 0)
8832 {
8833 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8834 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8835 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8836 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8837 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8838 }
8839 else
8840 {
8841 raw_control_state[14] = false;
8842 raw_control_state[15] = false;
8843 raw_control_state[16] = false;
8844 raw_control_state[17] = false;
8845 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8846 }
8847 }
8848
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7800706 times.
7800709 if (replay_is_active())
8849 {
8850
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 6785491 times.
7800706 if (replay_get_version() < 3)
8851 1015215 replay_poll();
8852
3/4
✓ Branch 0 taken 6785491 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5024116 times.
✓ Branch 3 taken 1761375 times.
6785491 else if (replay_is_replaying() && replay_get_version() < 6)
8853 1761375 replay_peek_input();
8854
3/4
✓ Branch 0 taken 5024116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2056603 times.
✓ Branch 3 taken 2967513 times.
5024116 else if (replay_is_replaying() && replay_version_check(8, 11))
8855 2967513 replay_peek_input();
8856
2/2
✓ Branch 0 taken 6696416 times.
✓ Branch 1 taken 1104290 times.
7800706 if (replay_get_version() == 8)
8857 1104290 update_keys();
8858 7800706 }
8859
8860 // Some test replay files were made before a serious input bug was fixed, so instead
8861 // of re-doing them or tossing them out, just check for that zplay version.
8862
3/4
✓ Branch 0 taken 7800703 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 7678803 times.
7800709 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8863
2/2
✓ Branch 0 taken 140412654 times.
✓ Branch 1 taken 7800703 times.
148213357 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8864 {
8865 140412654 control_state[i] = raw_control_state[i];
8866
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 90925344 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
140412654 if (botched_input && !control_state[i])
8867 47077142 down_control_states[i] = false;
8868 140412654 }
8869 7800703 bool did_bad_cutscene_btn = false;
8870
2/2
✓ Branch 0 taken 7800703 times.
✓ Branch 1 taken 140412654 times.
148213357 for(int q = 0; q < 18; ++q)
8871
4/4
✓ Branch 0 taken 6464476 times.
✓ Branch 1 taken 133948178 times.
✓ Branch 2 taken 6463742 times.
✓ Branch 3 taken 734 times.
140413388 if(control_state[q] && !active_cutscene.can_button(q))
8872 {
8873 734 control_state[q] = false;
8874 734 did_bad_cutscene_btn = true;
8875 734 }
8876
2/2
✓ Branch 0 taken 7800188 times.
✓ Branch 1 taken 515 times.
7800703 if(did_bad_cutscene_btn)
8877 515 active_cutscene.error();
8878
8879 7800703 button_press[0]=rButton(control_state[0],button_hold[0]);
8880 7800703 button_press[1]=rButton(control_state[1],button_hold[1]);
8881 7800703 button_press[2]=rButton(control_state[2],button_hold[2]);
8882 7800703 button_press[3]=rButton(control_state[3],button_hold[3]);
8883 7800703 button_press[4]=rButton(control_state[4],button_hold[4]);
8884 7800703 button_press[5]=rButton(control_state[5],button_hold[5]);
8885 7800703 button_press[6]=rButton(control_state[6],button_hold[6]);
8886 7800703 button_press[7]=rButton(control_state[7],button_hold[7]);
8887 7800703 button_press[8]=rButton(control_state[8],button_hold[8]);
8888 7800703 button_press[9]=rButton(control_state[9],button_hold[9]);
8889 7800703 button_press[10]=rButton(control_state[10],button_hold[10]);
8890 7800703 button_press[11]=rButton(control_state[11],button_hold[11]);
8891 7800703 button_press[12]=rButton(control_state[12],button_hold[12]);
8892 7800703 button_press[13]=rButton(control_state[13],button_hold[13]);
8893 7800703 button_press[14]=rButton(control_state[14],button_hold[14]);
8894 7800703 button_press[15]=rButton(control_state[15],button_hold[15]);
8895 7800703 button_press[16]=rButton(control_state[16],button_hold[16]);
8896 7800703 button_press[17]=rButton(control_state[17],button_hold[17]);
8897 7800703 }
8898
8899 // Returns true if any game key is pressed. This is needed because keypressed()
8900 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8901 40248748 bool zc_key_pressed()
8902 //may also need to use zc_getrawkey
8903 {
8904
7/10
✓ Branch 0 taken 32596311 times.
✓ Branch 1 taken 7652437 times.
✓ Branch 2 taken 7652437 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7652437 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6396064 times.
✓ Branch 7 taken 6396064 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2461637 times.
42710385 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8905
4/6
✓ Branch 0 taken 6396064 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6396064 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4843948 times.
✓ Branch 5 taken 4843948 times.
6396064 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8906
4/6
✓ Branch 0 taken 4843948 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4843948 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3143103 times.
✓ Branch 5 taken 3143103 times.
4843948 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8907
4/6
✓ Branch 0 taken 3143103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3143103 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2732161 times.
✓ Branch 5 taken 2732161 times.
3143103 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8908
1/2
✓ Branch 0 taken 2732161 times.
✗ Branch 1 not taken.
2732161 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8909
3/4
✓ Branch 0 taken 2612754 times.
✓ Branch 1 taken 119407 times.
✓ Branch 2 taken 2612754 times.
✗ Branch 3 not taken.
2732161 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8910
3/4
✓ Branch 0 taken 2493851 times.
✓ Branch 1 taken 118903 times.
✓ Branch 2 taken 2493851 times.
✗ Branch 3 not taken.
2612754 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8911
3/4
✓ Branch 0 taken 2478706 times.
✓ Branch 1 taken 15145 times.
✓ Branch 2 taken 2478706 times.
✗ Branch 3 not taken.
2493851 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8912
3/4
✓ Branch 0 taken 2465207 times.
✓ Branch 1 taken 13499 times.
✓ Branch 2 taken 2465207 times.
✗ Branch 3 not taken.
2478706 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8913
3/4
✓ Branch 0 taken 2462713 times.
✓ Branch 1 taken 2494 times.
✓ Branch 2 taken 2462713 times.
✗ Branch 3 not taken.
2465207 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8914
3/4
✓ Branch 0 taken 2462495 times.
✓ Branch 1 taken 218 times.
✓ Branch 2 taken 2462495 times.
✗ Branch 3 not taken.
2462713 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8915
3/4
✓ Branch 0 taken 2461656 times.
✓ Branch 1 taken 839 times.
✓ Branch 2 taken 2461656 times.
✗ Branch 3 not taken.
2462495 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8916
2/4
✓ Branch 0 taken 2461656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461656 times.
✗ Branch 3 not taken.
2461656 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8917
2/2
✓ Branch 0 taken 2461637 times.
✓ Branch 1 taken 19 times.
2461656 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8918 72017663 return true;
8919
8920 2461637 return false;
8921 9286678 }
8922
8923 149987254 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8924 {
8925 149987254 bool ret = false, drunkstate = false, rawret = false;;
8926 149987254 bool* flag = &down_control_states[btn];
8927
2/7
✓ Branch 0 taken 140691239 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9296015 times.
149987254 switch(btn)
8928 {
8929 case btnF12:
8930 ret = zc_getkey(KEY_F12, ignoreDisable);
8931 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8932 eatEntirely = false;
8933 break;
8934 case btnF11:
8935 ret = zc_getkey(KEY_F11, ignoreDisable);
8936 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8937 eatEntirely = false;
8938 break;
8939 case btnF5:
8940 ret = zc_getkey(KEY_F5, ignoreDisable);
8941 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8942 eatEntirely = false;
8943 break;
8944 case btnQ:
8945 ret = zc_getkey(KEY_Q, ignoreDisable);
8946 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8947 eatEntirely = false;
8948 break;
8949 case btnI:
8950 ret = zc_getkey(KEY_I, ignoreDisable);
8951 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8952 eatEntirely = false;
8953 break;
8954 case btnM:
8955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9296015 times.
9296015 if(FFCore.kb_typing_mode) return false;
8956 9296015 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8957 9296015 eatEntirely = false;
8958 9296015 break;
8959 default: //control_state[] index
8960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140691239 times.
140691239 if(FFCore.kb_typing_mode) return false;
8961
5/6
✓ Branch 0 taken 139891460 times.
✓ Branch 1 taken 799779 times.
✓ Branch 2 taken 2227822 times.
✓ Branch 3 taken 137663638 times.
✓ Branch 4 taken 2227822 times.
✗ Branch 5 not taken.
140691239 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8962
2/2
✓ Branch 0 taken 8035911 times.
✓ Branch 1 taken 132655328 times.
140691239 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8963
4/4
✓ Branch 0 taken 126551983 times.
✓ Branch 1 taken 14139256 times.
✓ Branch 2 taken 3004 times.
✓ Branch 3 taken 14136252 times.
154830495 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8964 140691239 rawret = raw_control_state[btn];
8965 140691239 }
8966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149987254 times.
149987254 assert(flag);
8967
2/2
✓ Branch 0 taken 95507848 times.
✓ Branch 1 taken 54479406 times.
149987254 if(press)
8968 {
8969
2/2
✓ Branch 0 taken 2888985 times.
✓ Branch 1 taken 51590421 times.
54479406 if(peek)
8970 2888985 ret = rButtonPeek(ret, *flag);
8971
2/2
✓ Branch 0 taken 50384650 times.
✓ Branch 1 taken 1205771 times.
51590421 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
8972 1205771 else ret = rButton(ret, *flag, rawret);
8973 54479406 }
8974
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 149987254 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
149987254 if(eatEntirely && ret) control_state[btn] = false;
8975
3/4
✓ Branch 0 taken 112368335 times.
✓ Branch 1 taken 37618919 times.
✓ Branch 2 taken 112368335 times.
✗ Branch 3 not taken.
149987254 if(drunk && drunkstate) ret = !ret;
8976 149987254 return ret;
8977 149987254 }
8978
8979 7464828 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8980 {
8981 7464828 byte ret = 0;
8982
2/2
✓ Branch 0 taken 5485508 times.
✓ Branch 1 taken 1979320 times.
7464828 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
8983
2/2
✓ Branch 0 taken 7334014 times.
✓ Branch 1 taken 130814 times.
7464828 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
8984
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
8985
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
8986
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
8987
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
8988
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
8989
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
8990 7464828 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
8991 }
8992
8993 1114 byte checkIntBtnVal(byte intbtn, byte vals)
8994 {
8995 1114 return intbtn&vals;
8996 }
8997
8998 1767383 bool Up()
8999 {
9000 1767383 return getInput(btnUp);
9001 }
9002 147167 bool Down()
9003 {
9004 147167 return getInput(btnDown);
9005 }
9006 257581 bool Left()
9007 {
9008 257581 return getInput(btnLeft);
9009 }
9010 286774 bool Right()
9011 {
9012 286774 return getInput(btnRight);
9013 }
9014 164908 bool cAbtn()
9015 {
9016 164908 return getInput(btnA);
9017 }
9018 1411891 bool cBbtn()
9019 {
9020 1411891 return getInput(btnB);
9021 }
9022 bool cSbtn()
9023 {
9024 return getInput(btnS);
9025 }
9026 68744 bool cLbtn()
9027 {
9028 68744 return getInput(btnL);
9029 }
9030 68744 bool cRbtn()
9031 {
9032 68744 return getInput(btnR);
9033 }
9034 bool cPbtn()
9035 {
9036 return getInput(btnP);
9037 }
9038 bool cEx1btn()
9039 {
9040 return getInput(btnEx1);
9041 }
9042 bool cEx2btn()
9043 {
9044 return getInput(btnEx2);
9045 }
9046 bool cEx3btn()
9047 {
9048 return getInput(btnEx3);
9049 }
9050 bool cEx4btn()
9051 {
9052 return getInput(btnEx4);
9053 }
9054 bool AxisUp()
9055 {
9056 return getInput(btnAxisUp);
9057 }
9058 bool AxisDown()
9059 {
9060 return getInput(btnAxisDown);
9061 }
9062 bool AxisLeft()
9063 {
9064 return getInput(btnAxisLeft);
9065 }
9066 bool AxisRight()
9067 {
9068 return getInput(btnAxisRight);
9069 }
9070
9071 bool cMbtn()
9072 {
9073 return getInput(btnM);
9074 }
9075 bool cF12()
9076 {
9077 return getInput(btnF12);
9078 }
9079 bool cF11()
9080 {
9081 return getInput(btnF11);
9082 }
9083 bool cF5()
9084 {
9085 return getInput(btnF5);
9086 }
9087 bool cQ()
9088 {
9089 return getInput(btnQ);
9090 }
9091 bool cI()
9092 {
9093 return getInput(btnI);
9094 }
9095
9096 130270 bool rUp()
9097 {
9098 130270 return getInput(btnUp, true);
9099 }
9100 130174 bool rDown()
9101 {
9102 130174 return getInput(btnDown, true);
9103 }
9104 130122 bool rLeft()
9105 {
9106 130122 return getInput(btnLeft, true);
9107 }
9108 129657 bool rRight()
9109 {
9110 129657 return getInput(btnRight, true);
9111 }
9112 1296 bool rAbtn()
9113 {
9114 1296 return getInput(btnA, true);
9115 }
9116 1296 bool rBbtn()
9117 {
9118 1296 return getInput(btnB, true);
9119 }
9120 7396643 bool rSbtn()
9121 {
9122 7396643 return getInput(btnS, true);
9123 }
9124 9286678 bool rMbtn()
9125 {
9126 9286678 return getInput(btnM, true);
9127 }
9128 129441 bool rLbtn()
9129 {
9130 129441 return getInput(btnL, true);
9131 }
9132 129436 bool rRbtn()
9133 {
9134 129436 return getInput(btnR, true);
9135 }
9136 7333107 bool rPbtn()
9137 {
9138 7333107 return getInput(btnP, true);
9139 }
9140 bool rEx1btn()
9141 {
9142 return getInput(btnEx1, true);
9143 }
9144 bool rEx2btn()
9145 {
9146 return getInput(btnEx2, true);
9147 }
9148 140087 bool rEx3btn()
9149 {
9150 140087 return getInput(btnEx3, true);
9151 }
9152 140087 bool rEx4btn()
9153 {
9154 140087 return getInput(btnEx4, true);
9155 }
9156 bool rAxisUp()
9157 {
9158 return getInput(btnAxisUp, true);
9159 }
9160 bool rAxisDown()
9161 {
9162 return getInput(btnAxisDown, true);
9163 }
9164 bool rAxisLeft()
9165 {
9166 return getInput(btnAxisLeft, true);
9167 }
9168 bool rAxisRight()
9169 {
9170 return getInput(btnAxisRight, true);
9171 }
9172
9173 bool rF11()
9174 {
9175 return getInput(btnF11, true);
9176 }
9177 bool rQ()
9178 {
9179 return getInput(btnQ, true);
9180 }
9181 bool rI()
9182 {
9183 return getInput(btnI, true);
9184 }
9185
9186 18226189 bool DrunkUp()
9187 {
9188 18226189 return getInput(btnUp, false, true);
9189 }
9190 16889179 bool DrunkDown()
9191 {
9192 16889179 return getInput(btnDown, false, true);
9193 }
9194 10288364 bool DrunkLeft()
9195 {
9196 10288364 return getInput(btnLeft, false, true);
9197 }
9198 8834095 bool DrunkRight()
9199 {
9200 8834095 return getInput(btnRight, false, true);
9201 }
9202 8035553 bool DrunkcAbtn()
9203 {
9204 8035553 return getInput(btnA, false, true);
9205 }
9206 8017001 bool DrunkcBbtn()
9207 {
9208 8017001 return getInput(btnB, false, true);
9209 }
9210 7263977 bool DrunkcEx1btn()
9211 {
9212 7263977 return getInput(btnEx1, false, true);
9213 }
9214 7263997 bool DrunkcEx2btn()
9215 {
9216 7263997 return getInput(btnEx2, false, true);
9217 }
9218 bool DrunkcSbtn()
9219 {
9220 return getInput(btnS, false, true);
9221 }
9222 bool DrunkcMbtn()
9223 {
9224 return getInput(btnM, false, true);
9225 }
9226 bool DrunkcLbtn()
9227 {
9228 return getInput(btnL, false, true);
9229 }
9230 bool DrunkcRbtn()
9231 {
9232 return getInput(btnR, false, true);
9233 }
9234 bool DrunkcPbtn()
9235 {
9236 return getInput(btnP, false, true);
9237 }
9238
9239 bool DrunkrUp()
9240 {
9241 return getInput(btnUp, true, true);
9242 }
9243 bool DrunkrDown()
9244 {
9245 return getInput(btnDown, true, true);
9246 }
9247 bool DrunkrLeft()
9248 {
9249 return getInput(btnLeft, true, true);
9250 }
9251 bool DrunkrRight()
9252 {
9253 return getInput(btnRight, true, true);
9254 }
9255 6081761 bool DrunkrAbtn()
9256 {
9257 6081761 return getInput(btnA, true, true);
9258 }
9259 6098593 bool DrunkrBbtn()
9260 {
9261 6098593 return getInput(btnB, true, true);
9262 }
9263 71669 bool DrunkrEx1btn()
9264 {
9265 71669 return getInput(btnEx1, true, true);
9266 }
9267 71662 bool DrunkrEx2btn()
9268 {
9269 71662 return getInput(btnEx2, true, true);
9270 }
9271 bool DrunkrEx3btn()
9272 {
9273 return getInput(btnEx3, true, true);
9274 }
9275 bool DrunkrEx4btn()
9276 {
9277 return getInput(btnEx4, true, true);
9278 }
9279 bool DrunkrSbtn()
9280 {
9281 return getInput(btnS, true, true);
9282 }
9283 bool DrunkrMbtn()
9284 {
9285 return getInput(btnM, true, true);
9286 }
9287 6688759 bool DrunkrLbtn()
9288 {
9289 6688759 return getInput(btnL, true, true);
9290 }
9291 6685284 bool DrunkrRbtn()
9292 {
9293 6685284 return getInput(btnR, true, true);
9294 }
9295 bool DrunkrPbtn()
9296 {
9297 return getInput(btnP, true, true);
9298 }
9299
9300 9337 void eat_buttons()
9301 {
9302 9337 getInput(btnA, true, false, true);
9303 9337 getInput(btnB, true, false, true);
9304 9337 getInput(btnS, true, false, true);
9305 9337 getInput(btnM, true, false, true);
9306 9337 getInput(btnL, true, false, true);
9307 9337 getInput(btnR, true, false, true);
9308 9337 getInput(btnP, true, false, true);
9309 9337 getInput(btnEx1, true, false, true);
9310 9337 getInput(btnEx2, true, false, true);
9311 9337 getInput(btnEx3, true, false, true);
9312 9337 getInput(btnEx4, true, false, true);
9313 9337 }
9314
9315 // Is true for the _first frame_ of a key press.
9316 // But! it is possible that a script manually sets the value of KeyPress,
9317 // in which case it will be restored to the "true" value based on `key_current_frame`
9318 // and `key_previous_frame` on the next frame.
9319 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9320 {
9321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9323 {
9324 case KEY_F7:
9325 case KEY_F8:
9326 case KEY_F9:
9327 return KeyPress[k];
9328
9329 default:
9330
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 return KeyPress[k] && !disabledKeys[k];
9331 }
9332 14 }
9333
9334 // Is true for _every frame_ a key is held down.
9335 // But! it is possible that a script manually sets the value of KeyInput,
9336 // in which case it will be restored to the "true" value based on `key_current_frame`
9337 // on the next frame.
9338 bool zc_getkey(int32_t k, bool ignoreDisable)
9339 {
9340 if(ignoreDisable) return KeyInput[k];
9341 switch(k)
9342 {
9343 case KEY_F7:
9344 case KEY_F8:
9345 case KEY_F9:
9346 return KeyInput[k];
9347
9348 default:
9349 return KeyInput[k] && !disabledKeys[k];
9350 }
9351 }
9352
9353 // Reads (and then clears) the current frame key state directly.
9354 // Scripts can also modify `key_current_frame`.
9355 303 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9356 {
9357
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 301 times.
303 if(zc_getrawkey(k, ignoreDisable))
9358 {
9359 2 _key[k]=key[k]=key_current_frame[k]=0;
9360 2 return true;
9361 }
9362 301 _key[k]=key[k]=key_current_frame[k]=0;
9363 301 return false;
9364 303 }
9365
9366 // Reads the current frame key state directly.
9367 // Scripts can also modify `key_current_frame`.
9368 63249747 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9369 {
9370
2/2
✓ Branch 0 taken 53963041 times.
✓ Branch 1 taken 9286706 times.
63249747 if(ignoreDisable) return key_current_frame[k];
9371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286706 times.
9286706 switch(k)
9372 {
9373 case KEY_F7:
9374 case KEY_F8:
9375 case KEY_F9:
9376 return key_current_frame[k];
9377
9378 default:
9379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286706 times.
9286706 return key_current_frame[k] && !disabledKeys[k];
9380 }
9381 63249747 }
9382
9383 // Only used for a handful of keys, like tilde and Function keys.
9384 // This state is never read within the game.
9385 // It exists so that all keyboard input still functions during replay,
9386 // without inadvertently doing things like toggling throttling if the player
9387 // presses ~
9388 9286678 bool zc_get_system_key(int32_t k)
9389 {
9390 9286678 return key_system[k];
9391 }
9392
9393 // True for the _first_ frame of a key press.
9394 83580102 bool zc_read_system_key(int32_t k)
9395 {
9396 83580102 return key_system_press[k];
9397 }
9398
9399 1179408106 bool is_system_key(int32_t k)
9400 {
9401
2/2
✓ Branch 0 taken 1095828004 times.
✓ Branch 1 taken 83580102 times.
1179408106 switch (k)
9402 {
9403 case KEY_BACKQUOTE:
9404 case KEY_CLOSEBRACE:
9405 case KEY_END:
9406 case KEY_HOME:
9407 case KEY_OPENBRACE:
9408 case KEY_PGDN:
9409 case KEY_PGUP:
9410 case KEY_TAB:
9411 case KEY_TILDE:
9412 83580102 return true;
9413 }
9414 1095828004 return is_Fkey(k);
9415 1179408106 }
9416
9417 9286678 void update_system_keys()
9418 {
9419
2/2
✓ Branch 0 taken 1179408106 times.
✓ Branch 1 taken 9286678 times.
1188694784 for (int32_t q = 0; q < 127; ++q)
9420 {
9421
2/2
✓ Branch 0 taken 195020238 times.
✓ Branch 1 taken 984387868 times.
1179408106 if (!is_system_key(q))
9422 984387868 continue;
9423
9424 195020238 key_system[q] = key[q];
9425
1/2
✓ Branch 0 taken 195020238 times.
✗ Branch 1 not taken.
195020238 key_system_press[q] = key_system[q] && !key_system_previous[q];
9426 195020238 key_system_previous[q] = key_system[q];
9427 195020238 }
9428 9286678 }
9429
9430 10390968 void update_keys()
9431 {
9432
2/2
✓ Branch 0 taken 1319652936 times.
✓ Branch 1 taken 10390968 times.
1330043904 for (int32_t q = 0; q < 127; ++q)
9433 {
9434 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9435
1/2
✓ Branch 0 taken 1319652936 times.
✗ Branch 1 not taken.
1319652936 if (!replay_is_replaying())
9436 key_current_frame[q] = key[q];
9437
9438
2/2
✓ Branch 0 taken 1309864938 times.
✓ Branch 1 taken 9787998 times.
1319652936 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9439 1319652936 KeyInput[q] = key_current_frame[q];
9440 1319652936 key_previous_frame[q] = key_current_frame[q];
9441 1319652936 }
9442 10390968 }
9443
9444 bool zc_disablekey(int32_t k, bool val)
9445 {
9446 switch(k)
9447 {
9448 case KEY_F7:
9449 case KEY_F8:
9450 case KEY_F9:
9451 return false;
9452
9453 default:
9454 disabledKeys[k] = val;
9455 return true;
9456 }
9457 }
9458
9459 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9460 {
9461 timer=timer;
9462 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9463 }
9464